The Stack Class is privately derived from SequentialList. It implements a stack, which is equivalent to a LIFO queue.

Class Stack



Pointer accessTop ()

return the top of the stack without removing it (return zero if empty)

void initialize ()

remove all elements from the stack

Pointer popTop ()

return and remove the top element from the stack (zero if empty)

void pushBottom (Pointer p)

add the element p to the bottom of the stack

void pushTop (Pointer p)

add the element p to the top of the stack

int size ()

return the number of elements in the stack