Queues
A queue object, queue
, is a FIFO (first-in-first-out) container type.
-
$queue() -> queue
-
Creates a new
queue
object.
Methods
-
:clear()
-
Removes all items from the queue.
-
:count() -> i64
-
Returns the number of items in the queue.
-
:dequeue() -> any
-
Removes and returns the next item from the queue. Returns an
err
if the queue is empty. -
:enqueue(item: any)
-
Adds a new item to the queue.
-
:is_empty() -> bool
-
Returns
true
if the queue is empty. -
:peek() -> any
-
Returns the next item from the queue without removing it. Returns an
err
if the queue is empty.