Tools.h++ Manual

104011 Tandem Computers Incorporated 22-73
22
Example In this example a stack of ints, implemented as an ordered vector, is exercised.
Program output:
6
5
1
Public constructor
RWTStack<T,C>();
Constructs an empty stack of objects of type
T
, implemented using class
C
.
Public member functions
void clear();
Removes all items from the stack.
size_t entries() const;
Returns the number of items currently on the stack.
RWBoolean isEmpty() const;
Returns
TRUE
if there are currently no items on the stack,
FALSE
otherwise.
void push(const T& a);
Push the item
a
onto the top of the stack.
#include <rw/tstack.h>
#include <rw/tvordvec.h>
#include <rw/rstream.h>
main() {
RWTStack<int, RWTValOrderedVector<int> > stack;
stack.push(1);
stack.push(5);
stack.push(6);
while (!stack.isEmpty())
cout << stack.pop() << endl;
return 0;
}