-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.hpp
56 lines (46 loc) · 2.11 KB
/
stack.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/// @author - Brandon Wallace
/// @file - stack.hpp
/// @brief - Stack Adapter
#ifndef Stack_h
#define Stack_h
// Stack Adapter
template <class T>
class Stack : protected List<T>
{
// Member Types
public:
using value_type = typename List<T>::value_type; ///< The value type
using reference = typename List<T>::reference; ///< The reference type
using size_type = typename List<T>::size_type; ///< The size type
public:
/// ----------------------------------------------------------------------
/// @name Stack()
/// @note Stack constructor user member initiailization to initialize the
/// elements within the container
/// ----------------------------------------------------------------------
Stack() : List<T>() {}
/// ----------------------------------------------------------------------
/// @name empty()
/// @note checks if the stack is empty
/// @return returns true if the stack is empty, false if not empty
/// ----------------------------------------------------------------------
bool empty() const { return empty(); }
/// ----------------------------------------------------------------------
/// @name top()
/// @note calls the back() function to return the top element of the stack
/// @return returns the top element of the stack
/// ----------------------------------------------------------------------
reference top() { return back(); }
/// ----------------------------------------------------------------------
/// @name push()
/// @param value holds the value to be inserted into the stack
/// @note inserts an element (value) onto the top of the stack
/// ----------------------------------------------------------------------
void push(const value_type& value) { push_back(value); }
/// ----------------------------------------------------------------------
/// @name pop()
/// @note pops off the top element of the stack
/// ----------------------------------------------------------------------
void pop() { pop_back(); }
}; // class Stack
#endif /* Stack_h */