Imperative deque
This structure provides fast access to its front and back elements, with O(1) operations.
Contains 'a elements, queue in both ways
Sourceval equal : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool equal a b checks whether a and b contain the same sequence of elements.
Sourceval compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int compare a b compares lexicographically a and b.
Number of elements. Used to be linear time, now constant time.
Sourceval push_front : 'a t -> 'a -> unit Sourceval push_back : 'a t -> 'a -> unit Sourceval peek_front_opt : 'a t -> 'a option Sourceval peek_back_opt : 'a t -> 'a option Sourceval remove_back : 'a t -> unit Remove last value. If the deque is empty do nothing
Sourceval remove_front : 'a t -> unit Remove first value. If the deque is empty do nothing
Sourceval take_back_opt : 'a t -> 'a option Sourceval take_front_opt : 'a t -> 'a option Sourceval update_back : 'a t -> ('a -> 'a option) -> unit Update last value. If the deque is empty do nothing. If the function returns None, remove last element; if it returns Some x, replace last element with x.
Sourceval update_front : 'a t -> ('a -> 'a option) -> unit Update first value. If the deque is empty do nothing. Similar to update_back but for the first value.
Sourceval append_front : into:'a t -> 'a t -> unit append_front ~into q adds all elements of q at the front of into. O(length q) in time.
Sourceval append_back : into:'a t -> 'a t -> unit append_back ~into q adds all elements of q at the back of into. O(length q) in time.
Sourceval iter : ('a -> unit) -> 'a t -> unit Sourceval fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b Conversions
Sourcetype 'a gen = unit -> 'a option Sourcetype 'a sequence = ('a -> unit) -> unit Create a deque from the sequence. Optional argument deque disappears, use add_seq_back instead.
of_gen g makes a deque containing the elements of g.
Iterate on the elements of the deque.
add_seq_front q seq adds elements of seq into the front of q, in reverse order. O(n) in time, where n is the number of elements to add.
add_seq_back q seq adds elements of seq into the back of q, in order. O(n) in time, where n is the number of elements to add.
Fresh copy, O(n) in time.
Sourceval of_list : 'a list -> 'a t Conversion from list, in order.
Sourceval to_list : 'a t -> 'a list List of elements, in order. Less efficient than to_rev_list.
Sourceval to_rev_list : 'a t -> 'a list Efficient conversion to list, in reverse order.
Sourceval filter : ('a -> bool) -> 'a t -> 'a t Sourceval filter_map : ('a -> 'b option) -> 'a t -> 'b t Filter map into a new copy
Sourceval filter_in_place : 'a t -> ('a -> bool) -> unit Keep only elements that satisfy the predicate.
print