Functional queues (fifo)
Simple implementation of functional queues
type 'a sequence = ('a -> unit) -> unittype 'a iter = ('a -> unit) -> unittype 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]type 'a gen = unit -> 'a optionQueue containing elements of type 'a
val is_empty : 'a t -> boolval push : 'a -> 'a t -> 'a tPush element at the end of the queue.
val snoc : 'a t -> 'a -> 'a tval peek : 'a t -> 'a optionFirst element of the queue.
val peek_exn : 'a t -> 'aval pop : 'a t -> ('a * 'a t) optionGet and remove the first element.
val pop_exn : 'a t -> 'a * 'a tSame as pop, but fails on empty queues.
Remove first element. If the queue is empty, do nothing.
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 map : ('a -> 'b) -> 'a t -> 'b tReverse the queue. Constant time.
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> boolmodule Infix : sig ... endinclude module type of Infix
val (>|=) : 'a t -> ('a -> 'b) -> 'b tval (@) : 'a t -> 'a t -> 'a tval (<::) : 'a t -> 'a -> 'a tNumber of elements in the queue (linear in time).
val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'bval iter : ('a -> unit) -> 'a t -> unitval to_list : 'a t -> 'a listval add_list : 'a t -> 'a list -> 'a tval of_list : 'a list -> 'a tval to_iter : 'a t -> 'a iterval add_iter : 'a t -> 'a iter -> 'a tval of_iter : 'a iter -> 'a tval to_std_seq : 'a t -> 'a Seq.tval add_std_seq : 'a t -> 'a Seq.t -> 'a tval of_std_seq : 'a Seq.t -> 'a tval to_klist : 'a t -> 'a klistval add_klist : 'a t -> 'a klist -> 'a tval of_klist : 'a klist -> 'a tval of_gen : 'a gen -> 'a tval add_gen : 'a t -> 'a gen -> 'a tval to_gen : 'a t -> 'a genIO