mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
feat: add CCVector.clear_and_reset
This commit is contained in:
parent
0ef454c6dc
commit
236a0c43ce
2 changed files with 9 additions and 0 deletions
|
|
@ -131,6 +131,10 @@ let clear v =
|
|||
OUnit.assert_bool "empty_after_clear" (Iter.is_empty (to_seq v));
|
||||
*)
|
||||
|
||||
let clear_and_reset v =
|
||||
v.size <- 0;
|
||||
v.vec <- [||]
|
||||
|
||||
let is_empty v = v.size = 0
|
||||
|
||||
let push_unsafe_ v x =
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ val init : int -> (int -> 'a) -> ('a, 'mut) t
|
|||
val clear : ('a, rw) t -> unit
|
||||
(** Clear the content of the vector. *)
|
||||
|
||||
val clear_and_reset : ('a, rw) t -> unit
|
||||
(** Clear the content of the vector, and deallocate the underlying array,
|
||||
removing references to all the elements.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val ensure_with : init:'a -> ('a, rw) t -> int -> unit
|
||||
(** Hint to the vector that it should have at least the given capacity.
|
||||
@param init if [capacity v = 0], used as a filler
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue