Data Structures in C++
Stack.hpp
Go to the documentation of this file.
1 /**
2  * @author Douglas De Rizzo Meneghetti (douglasrizzom@gmail.com)
3  * @date 2017-6-14
4  * @brief Abstract stack interface
5  */
6 
7 #ifndef AULA1_STACK_HPP
8 #define AULA1_STACK_HPP
9 
10 #include <string>
11 #include "DataStructure.hpp"
12 
13 //! Abstract stack interface.
14 //! \tparam T The type of object the data structure will contain
15 template<class T>
16 class Stack : public DataStructure {
17  public:
18 
19  std::string getName() { return "Stack Interface"; }
20 
21  //! Add an element to the top of the stack
22  //! \param val the value to be added to the stack
23  virtual void push(T val) =0;
24 
25  //! Remove an element from the top of the stack
26  //! \return the value that is being removed
27  virtual T pop() =0;
28 
29  //! See the value from the top of the stack, without removing it
30  //! \return The value on the top of the stack
31  virtual T peek() =0;
32 };
33 
34 #endif
std::string getName()
Provides the name of the data structure as a string representation.
Definition: Stack.hpp:19
Base class for all data structures.
virtual void push(T val)=0
Add an element to the top of the stack.
Abstract stack interface.
Definition: Stack.hpp:16
virtual T peek()=0
See the value from the top of the stack, without removing it.
virtual T pop()=0
Remove an element from the top of the stack.