◆ Stack()
template<class ItemType >
◆ ~Stack()
template<class ItemType >
Stack destructor. Must delete any allocated memory.
◆ clear()
template<class ItemType >
void Stack< ItemType >::clear |
( |
| ) |
|
Deletes all entries on the stack.
- Postcondition
- Stack contains no items, and the size of the stack is 0.
◆ isEmpty()
template<class ItemType >
bool Stack< ItemType >::isEmpty |
( |
| ) |
const |
Determines whether this stack is empty.
- Returns
- True if the stack has no items, or false if not.
◆ peek()
template<class ItemType >
ItemType Stack< ItemType >::peek |
( |
| ) |
const |
throw | ( | logic_error |
| ) | | |
Returns the top item off of the stack without removing it. The stack size stays the same.
- Returns
- Item of ItemType that was on the top of the stack. Throws an exception of type logic_error if the stack is empty.
◆ pop()
template<class ItemType >
bool Stack< ItemType >::pop |
( |
| ) |
|
Pops the top item off of the stack. The stack size is decreased by 1.
- Returns
- True if successful, or false otherwise.
◆ push()
template<class ItemType>
bool Stack< ItemType >::push |
( |
const ItemType & |
newItem | ) |
|
Pushes a new entry onto the top of the stack.
- Postcondition
- If successful, newItem is on the top of the stack.
- Parameters
-
newItem | The item (of datatype ItemType) to be pushed on top of the stack. |
- Returns
- True if insert was successful, or false if not.
◆ size()
template<class ItemType >
int Stack< ItemType >::size |
( |
| ) |
const |
Returns the number of items on the stack.
- Returns
- The integer number of items on the stack.
The documentation for this class was generated from the following files: