A templated stack collection class. The stack
is implemented as singly-linked list, and can be
traversed from the top to the bottom using the
first() / next() methods. The stack can only
store pointers to objects. Therefore, the declaration
   Stack SomeClass my_stack;
declares a stack of pointers of type SomeClass. Then, a stack
traversal is of the following form:
   SomeClass *ptr = my_stack.first();
   while (ptr) {
     ...
     ptr = my_stack.next();
   }
Elements are added and removed from the stack using
the standard push() and pop() routines.
Method Summary: | ||
Stack::Stack | (); | |
void | Stack::setAutoDelete | (bool b); |
void | Stack::clear | (); |
int | Stack::length | (); |
int | Stack::itemCount | (); |
type* | Stack::first | (); |
type* | Stack::next | (); |
void | Stack::push | (type* data); |
type* | Stack::pop | (); |
type* | Stack::peek | (); |
bool | Stack::isEmpty | (); |
Stack::Stack |
Stack::Stack(); Creates a new stack class. |
void Stack::setAutoDelete | ||||||
void Stack::setAutoDelete(bool b); or when the the list itself is deleted. | ||||||
|
void Stack::clear |
void Stack::clear(); Empties the stack, deleting any objects if auto-deletion is enabled. |
int Stack::length |
int Stack::length(); Returns the length of the stack. This is equivalent to itemCount(). |
int Stack::itemCount |
int Stack::itemCount(); Returns the length of the stack. This is equivalent to length() . |
type* Stack::first |
type* Stack::first(); Returns the top object in the stack. |
type* Stack::next |
type* Stack::next(); Returns the next object in the stack. |
void Stack::push | ||||||
void Stack::push(type* data); Pushes an object to the top of the stack. | ||||||
|
type* Stack::pop |
type* Stack::pop(); Removes the top item on the stack and returns it. Returns: If the stack is empty, NULL is returned. |
type* Stack::peek |
type* Stack::peek(); Returns the top object on the stack without removing it. Returns: NULL is returned if the stack is empty. |
bool Stack::isEmpty |
bool Stack::isEmpty(); Determines whether the stack has items in it. |