-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmystacks.cpp
90 lines (79 loc) · 1.49 KB
/
mystacks.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "mystacks.h"
/**
* @brief MyStackV::push Push t to the top of the vector based stack.
* @param t
*/
void MyStackV::push(Thing &t)
{
data.push_back(t);
}
/**
* @brief MyStackV::pop Pop from the top of the vector based stack.
*/
void MyStackV::pop()
{
data.pop_back();
}
/**
* @brief MyStackV::peek
* @return Return a reference to the .backp item in the stack.
*/
Thing &MyStackV::peek()
{
return data.back();
}
/**
* @brief MyStackV::size
* @return Return the number of items stored in the stack.
*/
size_t MyStackV::size() const
{
return data.size();
}
/**
* @brief MyStackV::empty
* @return Return a boolean value indicating whether the stack is empty.
*/
bool MyStackV::empty() const
{
return data.empty();
}
/**
* @brief MyStackLL::push Push t to the top of the Doubly Linked List based stack.
* @param t
*/
void MyStackLL::push(Thing &t)
{
data.push_back(t);
}
/**
* @brief MyStackLL::pop Pop from the top of the linked list based stack.
*/
void MyStackLL::pop()
{
data.pop_back();
}
/**
* @brief MyStackLL::peek
* @return Return a reference to the top item in the stack.
*/
Thing &MyStackLL::peek()
{
return data.back();
}
/**
* @brief MyStackLL::size
* @return Return the number of items stored in the stack.
*/
size_t MyStackLL::size() const
{
return data.size();
}
/**
* @brief MyStackLL::empty
* @return Return a boolean value indicating whether the stack is empty.
*/
bool MyStackLL::empty() const
{
return data.empty();
}