MutableQueue
A FIFO (first in first out) queue data structure.
add
let add: (t<'a>, 'a) => unitadd(q, x) adds the element x at the end of the queue q.
clear
let clear: t<'a> => unitDiscard all elements from the queue.
copy
let copy: t<'a> => t<'a>copy(q) returns a fresh queue.
forEach
let forEach: (t<'a>, 'a => unit) => unitforEach(q, f) appliesfin turn to all elements ofq`, from the least
recently entered to the most recently entered. The queue itself is unchanged.
forEachU
Deprecated
Use forEach instead
let forEachU: (t<'a>, 'a => unit) => unitfromArray
let fromArray: array<'a> => t<'a>fromArray a is equivalent to Array.forEach(a, add(q, a));
isEmpty
let isEmpty: t<'a> => boolReturns true if the given queue is empty, false otherwise.
make
let make: unit => t<'a>Returns a new queue, initially empty.
map
let map: (t<'a>, 'a => 'b) => t<'b>mapU
Deprecated
Use map instead
let mapU: (t<'a>, 'a => 'b) => t<'b>peek
let peek: t<'a> => option<'a>peekOpt(q) returns the first element in queue q, without removing it from the queue.
peekExn
let peekExn: t<'a> => 'apeekExn(q) throws an exception if q is empty.
peekOrThrow
let peekOrThrow: t<'a> => 'apeekOrThrow(q) throws an exception if q is empty.
peekUndefined
let peekUndefined: t<'a> => Js.undefined<'a>peekUndefined(q) returns undefined if not found.
pop
let pop: t<'a> => option<'a>pop(q) removes and returns the first element in queue q.
popExn
let popExn: t<'a> => 'apopExn(q) throw an exception if q is empty.
popOrThrow
let popOrThrow: t<'a> => 'apopOrThrow(q) throw an exception if q is empty.
popUndefined
let popUndefined: t<'a> => Js.undefined<'a>popUndefined(q) removes and returns the first element in queue q. it will
return undefined if it is already empty.
reduce
let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'breduce(q, accu, f) is equivalent to List.reduce(l, accu, f), where l is the
list of q's elements. The queue remains unchanged.
reduceU
Deprecated
Use reduce instead
let reduceU: (t<'a>, 'b, ('b, 'a) => 'b) => 'bsize
let size: t<'a> => intReturns the number of elements in a queue.
t
type t<'a>The type of queues containing elements of type('a).
toArray
let toArray: t<'a> => array<'a>First added will be in the beginning of the array.
transfer
let transfer: (t<'a>, t<'a>) => unittransfer(q1, q2) adds all of q1's elements at the end of the queue q2,
then clears q1. It is equivalent to the sequence forEach((x) => add(x, q2), q1);
clear q1, but runs in constant time.