Queue<Int> queue; Int x; queue(1); // enqueue queue.enqueue(2); // enqueue queue(3); // enqueue queue(4); // enqueue queue.dequeue(x); // dequeue cout << x << endl; ... while (queue.nelements() > 0) cout << queue() << " "; // dequeue cout << endl;
Presently the implementation is rather simple. It stores the elements in
a Block
To be used in a Queue, a class must have a default constructor, assignment
operator, and copy constructor.
Create a queue which is a copy of other. Compresses unused heap storage.
Create a queue which is a copy of other. Compresses unused heap storage.
Place an element in the queue. After calling this,
nelements() is increaed by one.
Short-hand for enqueue();
Place an element in the queue. After calling this,
nelements() is increaed by one.
Remove an element from the head of the queue and decrease
nelements() by one. If called when nelements() is zero, an
exception is thrown.
Short-hand for dequeue.
Remove an element from the head of the queue and decrease
nelements() by one. If called when nelements() is zero, an
exception is thrown.
Delete all the elements from the queue, and free up any resources.
Leave this queue logically unchanged, but remove unused storage.
With the present Block
How many elements are in the queue?
Motivation
This class was written for an application which thought it needed to queue
up some Glish events while it processed other Glish events. In fact that
application (Clean) was simplified so that it doesn't presently operate that
way.
To Do
Member Description
Queue()
Create a Queue with no elements.
Queue(const Queue<T> &other)
~Queue()
Queue<T> &operator=(const Queue<T> &other)
void operator()(const T &value)
void enqueue(const T &value)
T operator()()
void dequeue(T &value)
void clear()
void compress()
uInt nelements() const