Skip to content

Queue

class Queue<Type> < Object

First in, first-out (FIFO) queue. Beyond its typical uses, because Queue is a recursive data structure, it provides particularly good sharing under Birch's lazy deep clone mechanism.

Caution

See note under List for possible segfault issues on the destruction of large queues.

Member Functions

Name Description
size Number of elements.
empty Is this empty?
clear Clear all elements.
front Get the first element.
back Get the last element.
pushFront Insert a new element at the start.
pushBack Insert a new element at the end.
popFront Remove the first element and return it.
popBack Remove the last element and return it.
begin First node, if any.
end Last node, if any.
allForward Move all elements to the forward list.
allBackward Move all elements to the backward list.

Member Fibers

Name Description
walk Forward iteration.

Member Function Details

allBackward

function allBackward()

Move all elements to the backward list.

allForward

function allForward()

Move all elements to the forward list.

back

function back() -> Type

Get the last element.

begin

function begin() -> QueueNode<Type>?

First node, if any. This can be used to maintain a forward iterator over the container.

clear

function clear()

Clear all elements.

empty

function empty() -> Boolean

Is this empty?

end

function end() -> QueueNode<Type>?

Last node, if any. This can be used to maintain a backward iterator over the container.

front

function front() -> Type

Get the first element.

popBack

function popBack() -> Type

Remove the last element and return it.

popFront

function popFront() -> Type

Remove the first element and return it.

pushBack

function pushBack(x:Type)

Insert a new element at the end.

  • x: Value.

pushFront

function pushFront(x:Type)

Insert a new element at the start.

  • x: Value.

size

function size() -> Integer

Number of elements.

Member Fiber Details

walk

fiber walk() -> Type

Forward iteration.

Return: a fiber object that yields each element in forward order.