queues

popBack, popFront, pushBack, pushFront, queueSize, resetQueue


popBack

Syntax

<value> = popBack(@queue)

Description

Pops <value> from the back of the double-ended queue @queue. If @queue is empty an exception will be thrown. (@queue must have been initialized with resetQueue() prior to calling this routine.)

Examples

lastIn = popBack(@dq)

See Also

popFront, pushBack, pushFront, queueSize, resetQueue


popFront

Syntax

<value> = popFront(@queue)

Description

Pops <value> from the front of the double-ended queue @queue. If @queue is empty an exception will be thrown. (@queue must have been initialized with resetQueue() prior to calling this routine.)

Examples

firstOut = popFront(@dq)

See Also

popBack, pushBack, pushFront, queueSize, resetQueue


pushBack

Syntax

@queue = pushBack(@queue, <value>)

Description

Pushes <value> to the back of the double-ended queue @queue. The returned value is the input @queue reference. (@queue must have been initialized with resetQueue() prior to calling this routine.)

It is also legal to call append() to push several elements at once to a queue.

Examples

pushBack(@dq, 'lastIn')

See Also

append, popBack, popFront, pushFront, queueSize, resetQueue


pushFront

Syntax

@queue = pushFront(@queue, <value>)

Description

Pushes <value> to the front of the double-ended queue @queue. The returned value is the input @queue reference. (@queue must have been initialized with resetQueue() prior to calling this routine.)

Examples

pushFront(@dq, 'firstOut')

See Also

popBack, popFront, pushBack, queueSize, resetQueue


queueSize

Syntax

+count = queueSize(@queue)

Description

Returns the count of elements in the double-ended queue @queue. The count is defined by [@queue].n - [@queue].m (see resetQueue() for an explanation). (@queue must have been initialized with resetQueue() prior to calling this routine.)

Examples

count = queueSize(@dq)

See Also

popBack, popFront, pushBack, pushFront, resetQueue


resetQueue

Syntax

resetQueue(@queue)

Description

Initializes the "double-ended queue" referenced to by @queue for use with pushBack(), popFront() etc by setting the sub-elements [@queue].m and [@queue].n to 0.

[@queue].m is the index of the first element on the queue and it is decremented on pushFront() and incremented on popFront(). [@queue].n is one greater than the index of the last element on the queue and it is incremented on pushBack() and decremented on popBack(). (The 'm' and 'n' identifiers were chosen to make queue() compatible with some of the array functions such as append().)

Examples

resetQueue(@dq)

See Also

popBack, popFront, pushBack, pushFront, queueSize