Brumski's DSA Learning Project 1.3
For Learning Data Structures and Algorithms in C++
Loading...
Searching...
No Matches
MyStack< T > Class Template Reference

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.
 

Detailed Description

template<class T>
class MyStack< T >

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.

Constructor & Destructor Documentation

◆ MyStack()

template<class T >
MyStack< T >::MyStack ( MyStack< T > &&  other)
defaultnoexcept

Default Move constructor.

Parameters
other- the object that you want to transfer ownership from

Member Function Documentation

◆ operator=()

template<class T >
MyStack< T > & MyStack< T >::operator= ( MyStack< T > &&  other)
defaultnoexcept

Default Move assignment operator.

Parameters
other- the object that you want to transfer ownership from

◆ push_top()

template<class T >
virtual MyStack< T > & MyStack< T >::push_top ( const T &  value)
inlinevirtual

Pushes a new element to the top of the stack.

Parameters
value- The value you want to pass to the top of the stack

The documentation for this class was generated from the following file: