MP4
Stacks and Queues
|
Stack class: represents a standard stack. More...
#include "stack.h"
Public Member Functions | |
void | push (const T &newItem) |
Adds the parameter object to the top of the Stack. More... | |
T | pop () |
Removes the object on top of the Stack, and returns it. More... | |
void | add (const T &theItem) |
Adds an element to the ordering structure. More... | |
T | remove () |
Removes an element from the ordering structure. More... | |
T | peek () |
Finds the object on top of the Stack, and returns it to the caller. More... | |
bool | isEmpty () const |
Determines if the Stack is empty. More... | |
![]() | |
virtual | ~OrderingStructure () |
Destructor for the OrderingStructure. More... | |
Private Attributes | |
list< T > | myStack |
The list representing our Stack: the front of the list corresponds to the top of the Stack. More... | |
Stack class: represents a standard stack.
Templated to hold elements of any type.
You should not modify this file for the MP!
void Stack< T >::push | ( | const T & | newItem | ) |
T Stack< T >::pop | ( | ) |
Removes the object on top of the Stack, and returns it.
That is, remove the element at the beginning of the list. You may assume this function is only called when the Stack is not empty.
|
virtual |
Adds an element to the ordering structure.
Implements OrderingStructure< T >.
|
virtual |
Removes an element from the ordering structure.
Implements OrderingStructure< T >.
|
virtual |
Finds the object on top of the Stack, and returns it to the caller.
Unlike pop(), this operation does not alter the Stack itself. It should look at the beginning of the list. You may assume this function is only called when the Stack is not empty.
Implements OrderingStructure< T >.
|
virtual |
Determines if the Stack is empty.
Implements OrderingStructure< T >.