-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stack.inl
47 lines (43 loc) · 791 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
// -*- C++ -*-
// $Id: Stack.inl 827 2011-02-07 14:20:53Z hillj $
// Honor Pledge:
//
// I pledge that I have neither given nor received any help on
// this assignment.
//
// size
//
template <typename T>
inline
size_t Stack <T>::size (void) const
{
return array_.size ();
} // end size
//
// top
//
template <typename T>
inline
T Stack <T>::top (void) const
{
if (is_empty()) {
empty_exception ex;
throw ex;
} else {
// return the lastly added element
return array_.get (array_.size() - 1);
} // end if-else
} // end top
//
// is_empty
//
template <typename T>
inline
bool Stack <T>::is_empty (void) const
{
if (array_.size () == 0) {
return true;
} else {
return false;
} // end if-else
} // end is_empty