Legend:
Library
Module
Module type
Parameter
Class
Class type
A queue implemented with an array.
The implementation will grow the array as necessary. The array will never automatically be shrunk, but the size can be interrogated and set with capacity and set_capacity.
Iteration functions (iter, fold, map, concat_map, filter, filter_map, filter_inplace, and some functions from Container.S1) will raise if the queue is modified during iteration.
Also see Linked_queue, which has different performance characteristics.
val fold : 'at->init:'accum->f:('accum->'a->'accum)->'accum
fold t ~init ~f returns f (... f (f (f init e1) e2) e3 ...) en, where e1..en are the elements of t
val fold_result :
'at->init:'accum->f:('accum->'a->('accum, 'e)Result.t)->('accum, 'e)Result.t
fold_result t ~init ~f is a short-circuiting version of fold that runs in the Result monad. If f returns an Error _, that value is returned without any additional invocations of f.
val fold_until :
'at->init:'accum->f:('accum->'a->('accum, 'final)Base__.Container_intf.Continue_or_stop.t)->finish:('accum->'final)->'final
fold_until t ~init ~f ~finish is a short-circuiting version of fold. If f returns Stop _ the computation ceases and results in that value. If f returns Continue _, the fold will proceed. If f never returns Stop _, the final result is computed by finish.
val min_elt : 'at->compare:('a->'a-> int)->'a option
Returns a minimum (resp maximum) element from the collection using the provided compare function, or None if the collection is empty. In case of a tie, the first element encountered while traversing the collection is returned. The implementation uses fold so it has the same complexity as fold.
val max_elt : 'at->compare:('a->'a-> int)->'a option
These are all like their equivalents in Container except that an index starting at 0 is added as the first argument to f.
of_list list returns a queue t with the elements of list in the same order as the elements of list (i.e. the first element of t is the first element of the list).
filter_inplace t ~f removes all elements of t that don't satisfy f. If f raises, t is unchanged. This is inplace in that it modifies t; however, it uses space linear in the final length of t.
val filteri_inplace : 'at->f:(int ->'a-> bool)-> unit
set_capacity t c sets the capacity of t's backing array to at least max c (length
t). If t's capacity changes, then this involves allocating a new backing array and copying the queue elements over. set_capacity may decrease the capacity of t, if c < capacity t.