DataStruct.h
defines two other generic container classes that are privately derived from SequentialList: Queue and Stack. Class Queue may be used to implement a FIFO or a LIFO queue, or a mixture. Class Stack implements a stack.
void putTail(Pointer p);In addition,
void putHead(Pointer p);
Pointer getHead();
Pointer getTail();
put
is a synonym for putTail,
and get
is a synonym for getHead.
All these functions are implemented on top of the (hidden) SequentialList functions. The SequentialList functions size
and initialize
are re-exported (that is, are accessible as public member functions of class Stack).
void pushTop(Pointer p);
Pointer popTop();
pushBottom(Pointer p);
pushTop
and popTop
are the functions traditionally associated with a stack; pushBottom
adds an item at the bottom, which is non-traditional. The following non-destructive function also exists:
Pointer accessTop() const;This accesses but does not remove the element from the top of the stack.
All these functions are implemented on top of the (hidden) SequentialList functions. The SequentialList functions
size
and initialize
are re-exported.