mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCVector.append_list
This commit is contained in:
parent
fb3ffa1bb5
commit
3a21aab9c8
2 changed files with 23 additions and 0 deletions
|
|
@ -222,6 +222,25 @@ let append_array a b =
|
|||
append_array v1 v2; to_list v1 = CCList.(0--9)
|
||||
*)
|
||||
|
||||
let append_list a b = match b with
|
||||
| [] -> ()
|
||||
| x :: _ ->
|
||||
(* need to push at least one elem *)
|
||||
let len_a = a.size in
|
||||
let len_b = List.length b in
|
||||
ensure_with ~init:x a (len_a + len_b);
|
||||
List.iter (push_unsafe_ a) b;
|
||||
()
|
||||
|
||||
(*$Q
|
||||
Q.(pair (list int)(list int)) (fun (l1,l2) -> \
|
||||
let v = of_list l1 in append_list v l2; \
|
||||
to_list v = (l1 @ l2))
|
||||
Q.(pair (list int)(list int)) (fun (l1,l2) -> \
|
||||
let v = of_list l1 in append_list v l2; \
|
||||
length v = List.length l1 + List.length l2)
|
||||
*)
|
||||
|
||||
(*$inject
|
||||
let gen x =
|
||||
let small = length in
|
||||
|
|
|
|||
|
|
@ -98,6 +98,10 @@ val append_array : ('a, rw) t -> 'a array -> unit
|
|||
val append_seq : ('a, rw) t -> 'a sequence -> unit
|
||||
(** Append content of sequence *)
|
||||
|
||||
val append_list : ('a, rw) t -> 'a list -> unit
|
||||
(** Append content of list
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val equal : 'a equal -> ('a,_) t equal
|
||||
|
||||
val compare : 'a ord -> ('a,_) t ord
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue