mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 19:55:31 -05:00
add CCFQueue.rev
This commit is contained in:
parent
27e63e6cfa
commit
d4ccbccbb8
2 changed files with 15 additions and 0 deletions
|
|
@ -371,6 +371,16 @@ let of_seq seq =
|
|||
Sequence.of_list l |> of_seq |> to_list = l)
|
||||
*)
|
||||
|
||||
let rev q =
|
||||
let q' = ref empty in
|
||||
iter (fun x -> q' := cons x !q') q;
|
||||
!q'
|
||||
|
||||
(*$Q
|
||||
(Q.list Q.int) (fun l -> \
|
||||
of_list l |> rev |> to_list = List.rev l)
|
||||
*)
|
||||
|
||||
let _nil () = `Nil
|
||||
let _single x cont () = `Cons (x, cont)
|
||||
let _double x y cont () = `Cons (x, _single y cont)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,10 @@ val append : 'a t -> 'a t -> 'a t
|
|||
after elements of the first one.
|
||||
Linear in the size of the second queue. *)
|
||||
|
||||
val rev : 'a t -> 'a t
|
||||
(** Reverse the queue, O(n) complexity
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val map : ('a -> 'b) -> 'a t -> 'b t
|
||||
(** Map values *)
|
||||
|
||||
|
|
@ -131,6 +135,7 @@ val of_list : 'a list -> 'a t
|
|||
val to_list : 'a t -> 'a list
|
||||
|
||||
val add_seq_front : 'a sequence -> 'a t -> 'a t
|
||||
|
||||
val add_seq_back : 'a t -> 'a sequence -> 'a t
|
||||
|
||||
val to_seq : 'a t -> 'a sequence
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue