-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.inl
54 lines (48 loc) · 779 Bytes
/
Stack.inl
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
// Honor Pledge:
//
// I pledge that I have neither given nor
// received any help on this assignment.
//
// blakbenn
//
// size
//
template <typename T>
inline
size_t Stack <T>::size (void) const
{
return this->arr.size();
}
//
// top
//
template <typename T>
inline
T Stack <T>::top (void) const
{
//check for empty Stack
if(this->is_empty())
{
//throw error if empty
throw empty_exception();
}
else
{
//otherwise get value off the top of the stack
return this->arr.get(this->arr.size()-1);
}
}
//
// is_empty
//
template <typename T>
inline
bool Stack <T>::is_empty (void) const
{
//if the size is zero, the stack is empty
if(this->size() == 0)
{
return true;
}
return false;
}