Checks whether the provided element is there, using polymorphic compare if equal
is not provided
fold t ~init ~f
returns f (... f (f (f init e1) e2) e3 ...) en
, where e1..en
are the elements of t
Returns true
if and only if there exists an element for which the provided
function evaluates to true
. This is a short-circuiting operation.
Returns true
if and only if the provided function evaluates to true
for all
elements. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
Returns as an option
the first element for which f
evaluates to true.
Returns the first evaluation of f
that returns Some
, and returns None
if there
is no such element.
Returns a minimum (resp maximum) element from the collection using the provided
cmp
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
.
create ?initial_length ?never_shrink ()
create a new t
. initial_length
is the
initial length of the dequeue; it will be able to hold initial_length
elements
without resizing. It must be positive. If never_shrink
is true, the physical array
will never shrink; only expand. If initial_length
is given without never_shrink
then never_shrink
is presumed to be true
, otherwise never_shrink
defaults to
false
.
front_index t
return the index of the front item in t
.
front_index_exn t
throws an exception if t
is empty, otherwise returns the index
of the front item in t
back_index t
return the index of the back item in t
.
back_index_exn t
throws an exception if t
is empty, otherwise returns the index
of the back item in t
get_opt t i
return the element at index i
. Return None
if i
is invalid.
get t i
return the element at index i
. Raise an exception if i
is
invalid.
set_exn t i v
mutate the element at i
.
iteri t ~f
iter over the elements of t `front_to_back
passing in the index.
foldi t ~init ~f
as fold
, but also passes in the index of the current element.
foldi' t ~init ~f
as fold'
, but also passes in the index of the current element to
f
.
clear t
removes all elements from t
.
drop ?n t back_or_front
drop n
elements (default 1) from the back_or_front
of
t
. If t
has fewer than n
elements then it is cleared.