popBack, popFront, pushBack, pushFront, queueSize, resetQueue
<value> = popBack(@queue)
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.)
lastIn = popBack(@dq)
<value> = popFront(@queue)
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.)
firstOut = popFront(@dq)
@queue = pushBack(@queue, <value>)
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.
pushBack(@dq, 'lastIn')
@queue = pushFront(@queue, <value>)
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.)
pushFront(@dq, 'firstOut')
+count = queueSize(@queue)
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.)
count = queueSize(@dq)
resetQueue(@queue)
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().)
resetQueue(@dq)