Go to the previous, next section.

Queues

Queues are declared as an "abstract" class. They are currently implemented in any of three ways.

VQueue
implement fixed sized Queues via arrays.

XPQueue
implement dynamically-sized Queues via XPlexes.

SLQueue
implement dynamically-size Queues via linked lists.

All possess the same capabilities; they differ only in constructors. VQueue constructors require a fixed maximum capacity argument. XPQueue constructors optionally take a chunk size argument. SLQueue constructors take no argument.

Assume the declaration of a base element x.

Queue q; or Queue q(int capacity);
declares a queue.

q.empty()
returns true if queue q is empty.

q.full()
returns true if queue q is full. XPQueues and SLQueues are never full.

q.length()
returns the current number of elements in the queue.

q.enq(x)
enqueues x on queue q.

x = q.deq()
dequeues and returns the front of queue

q.front()
returns a reference to the front of queue.

q.del_front()
dequeues, but does not return the front of queue

q.clear()
removes all elements from the queue.

Go to the previous, next section.