Tools.h++ Manual

22-70 104011 Tandem Computers Incorporated
22
Example In this example a queue of
RWCStrings
, implemented as a singly-linked list, is
exercised.
Program output:
one
two
three
Public constructor
RWTQueue<T>,C>();
Construct an empty queue of objects of type
T
, implemented using class
C
.
Public member functions
void clear();
Removes all items from the queue.
size_t entries() const;
Returns the number of items in the queue.
T first() const;
Returns, but does not remove, the first item in the queue (the item least
recently inserted into the queue).
#include <rw/tqueue.h>
#include <rw/cstring.h>
#include <rw/tvslist.h>
#include <rw/rstream.h>
main() {
RWTQueue<RWCString, RWTValSlist<RWCString> > queue;
queue.insert("one"); // Type conversion occurs
queue.insert("two");
queue.insert("three");
while (!queue.isEmpty())
cout << queue.get() << endl;
return 0;
}