|
Brumski's DSA Learning Project 1.3
For Learning Data Structures and Algorithms in C++
|
This is a template class that represents the stack data structure. More...
#include <stack_dsa.hpp>
Classes | |
| class | Node |
| This is a template class that represents a single element of a stack, and it will be called "Node". More... | |
Public Member Functions | |
| MyStack ()=default | |
| Default Constructor. | |
| MyStack (const MyStack< T > &)=delete | |
| Deleted copy constructor. | |
| MyStack (MyStack< T > &&other) noexcept=default | |
| Default Move constructor. | |
| MyStack< T > & | operator= (const MyStack< T > &)=delete |
| Deleted copy assignment operator. | |
| MyStack< T > & | operator= (MyStack< T > &&other) noexcept=default |
| Default Move assignment operator. | |
| virtual T | Top () |
| Returns the top element of the stack. | |
| virtual MyStack< T > & | push_top (const T &value) |
| Pushes a new element to the top of the stack. | |
| virtual MyStack< T > & | popTop () |
| Removes the top element of the stack. | |
| virtual bool | isEmpty () |
| Returns true if the stack is empty. | |
Private Attributes | |
| std::unique_ptr< Node< T > > | myTop |
| Pointer to the top element of the stack. | |
This is a template class that represents the stack data structure.
It can take any basic C++ data type. It uses the Last In First Out (LIFO) principle.
Default Move constructor.
| other | - the object that you want to transfer ownership from |
Default Move assignment operator.
| other | - the object that you want to transfer ownership from |
Pushes a new element to the top of the stack.
| value | - The value you want to pass to the top of the stack |