mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 20:55:31 -05:00
specify behavior of CCFQueue.take_{front,back}_l in some corner cases
This commit is contained in:
parent
d7b90d3ba3
commit
56928a1a15
2 changed files with 10 additions and 2 deletions
|
|
@ -132,6 +132,9 @@ let take_front q =
|
|||
with Empty -> None
|
||||
|
||||
let take_front_l n q =
|
||||
if n<0 then (
|
||||
invalid_arg "take_back_l: cannot take negative number of arguments"
|
||||
);
|
||||
let rec aux acc q n =
|
||||
if n=0 || is_empty q then List.rev acc, q
|
||||
else
|
||||
|
|
@ -183,6 +186,9 @@ let take_back q =
|
|||
with Empty -> None
|
||||
|
||||
let take_back_l n q =
|
||||
if n<0 then (
|
||||
invalid_arg "take_back_l: cannot take negative number of arguments"
|
||||
);
|
||||
let rec aux acc q n =
|
||||
if n=0 || is_empty q then q, acc
|
||||
else
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ val take_front_exn : 'a t -> ('a * 'a t)
|
|||
|
||||
val take_front_l : int -> 'a t -> 'a list * 'a t
|
||||
(** [take_front_l n q] takes at most [n] elements from the front
|
||||
of [q], and returns them wrapped in a list *)
|
||||
of [q], and returns them wrapped in a list
|
||||
@raise Invalid_argument if n<0 *)
|
||||
|
||||
val take_front_while : ('a -> bool) -> 'a t -> 'a list * 'a t
|
||||
|
||||
|
|
@ -51,7 +52,8 @@ val take_back_l : int -> 'a t -> 'a t * 'a list
|
|||
(** [take_back_l n q] removes and returns the last [n] elements of [q]. The
|
||||
elements are in the order of the queue, that is, the head of the returned
|
||||
list is the first element to appear via {!take_front}.
|
||||
[take_back_l 2 (of_list [1;2;3;4]) = of_list [1;2], [3;4]] *)
|
||||
[take_back_l 2 (of_list [1;2;3;4]) = of_list [1;2], [3;4]]
|
||||
@raise Invalid_argument if n<0 *)
|
||||
|
||||
val take_back_while : ('a -> bool) -> 'a t -> 'a t * 'a list
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue