Readonly
dequeueDequeues (removes oldest item / item at front of queue)
Use peek to look at the item at front of queue without removing it.
Readonly
enqueueEnqueues (adds items to back of queue). If a capacity is set, not all items might be added.
Rest
...toAdd: readonly V[]How many items were added
Returns true if queue is empty
Is queue full? Returns false if no capacity has been set
Number of items in queue
Removes values that match predicate
.
// Eg queue of strings, compare by value
queue.removeWhere(v => v === `someValue`);
// Eg queue of objects, compare by reference
queue.removeWhere(v => v === someTarget);
// Eg use ixfx function to compare value of objects, regardless of key ordering
queue.removeWhere(v => isEqualValueIgnoreOrder(v, someTarget));
Returns number of items removed.
Queue (mutable). See also IQueueImmutable for the immutable version.
Queues are useful if you want to treat 'older' or 'newer' items differently. Enqueing adds items at the back of the queue, while dequeing removes items from the front (ie. the oldest).
Example: Cap size to 5 items, throwing away newest items already in queue.