TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Class representation of a stack. More...
Public Member Functions | |
Stack (int size) | |
Constructs a new Stack object. | |
bool | full () const |
Checks if the stack is full. | |
bool | empty () const |
Checks if the stack is empty. | |
void | push (T element) |
Pushes an element onto the stack. | |
T | pop () |
Pops an element from the stack. | |
void | show () const |
Displays all elements in the stack. | |
T | topmost () const |
Displays the topmost element of the stack. | |
T | bottom () const |
Displays the bottom element of the stack. | |
Private Attributes | |
std::unique_ptr< T[]> | stack |
Smart pointer to the stack array. | |
int | stackSize |
Maximum size of the stack. | |
int | stackIndex |
Index pointing to the top element of the stack. | |
Class representation of a stack.
T | The type of the elements in the stack |
Definition at line 16 of file stack_using_array.cpp.
|
inline |
Constructs a new Stack object.
size | Maximum size of the stack |
Definition at line 28 of file stack_using_array.cpp.
|
inline |
Displays the bottom element of the stack.
std::out_of_range | if the stack is empty |
Definition at line 97 of file stack_using_array.cpp.
|
inline |
Checks if the stack is empty.
Definition at line 41 of file stack_using_array.cpp.
|
inline |
Checks if the stack is full.
Definition at line 35 of file stack_using_array.cpp.
|
inline |
Pops an element from the stack.
std::out_of_range | if the stack is empty |
Definition at line 62 of file stack_using_array.cpp.
|
inline |
Pushes an element onto the stack.
element | Element to push onto the stack |
Definition at line 48 of file stack_using_array.cpp.
|
inline |
Displays all elements in the stack.
Definition at line 72 of file stack_using_array.cpp.
|
inline |
Displays the topmost element of the stack.
std::out_of_range | if the stack is empty |
Definition at line 84 of file stack_using_array.cpp.
|
private |
Smart pointer to the stack array.
Definition at line 18 of file stack_using_array.cpp.
|
private |
Index pointing to the top element of the stack.
Definition at line 20 of file stack_using_array.cpp.
|
private |
Maximum size of the stack.
Definition at line 19 of file stack_using_array.cpp.