Module CCFQueue
Functional queues
type 'a sequence= ('a -> unit) -> unittype 'a klist= unit -> [ `Nil | `Cons of 'a * 'a klist ]type 'a equal= 'a -> 'a -> booltype 'a printer= Format.formatter -> 'a -> unit
Basics
val empty : 'a tval is_empty : 'a t -> boolval singleton : 'a -> 'a tval doubleton : 'a -> 'a -> 'a t
val take_front_exn : 'a t -> 'a * 'a tSame as
take_front, but fails on empty queues.- raises Empty
if the queue is empty.
val take_front_l : int -> 'a t -> 'a list * 'a ttake_front_l n qtakes at mostnelements from the front ofq, and returns them wrapped in a list.- raises Invalid_argument
if n<0.
val take_front_while : ('a -> bool) -> 'a t -> 'a list * 'a tval take_back : 'a t -> ('a t * 'a) optionTake last element.
val take_back_exn : 'a t -> 'a t * 'aSame as
take_back, but fails on empty queues.- raises Empty
if the queue is empty.
val take_back_l : int -> 'a t -> 'a t * 'a listtake_back_l n qremoves and returns the lastnelements ofq. The elements are in the order of the queue, that is, the head of the returned list is the first element to appear viatake_front.take_back_l 2 (of_list [1;2;3;4]) = of_list [1;2], [3;4].- raises Invalid_argument
if n<0.
Individual extraction
val first : 'a t -> 'a optionFirst element of the queue.
val last : 'a t -> 'a optionLast element of the queue.
Global Operations
val append : 'a t -> 'a t -> 'a tAppend two queues. Elements from the second one come after elements of the first one. Linear in the size of the second queue.
val size : 'a t -> intNumber of elements in the queue (constant time).
Conversions
val of_list : 'a list -> 'a tval to_list : 'a t -> 'a listval add_seq_front : 'a sequence -> 'a t -> 'a tval add_seq_back : 'a t -> 'a sequence -> 'a tval to_seq : 'a t -> 'a sequenceval of_seq : 'a sequence -> 'a tval to_klist : 'a t -> 'a klistval of_klist : 'a klist -> 'a tval (--) : int -> int -> int ta -- bis the integer range fromatob, both included.- since
- 0.10
val (--^) : int -> int -> int ta -- bis the integer range fromatob, wherebis excluded.- since
- 0.17