-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.h
60 lines (53 loc) · 1.04 KB
/
Stack.h
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
#ifndef STACK_H
#define STACK_H
#ifndef NULL
#define NULL 0
#endif
template <typename T>
class Stack
{
private:
class StackNode
{
public:
T Data;
StackNode* pNext;
StackNode(T data) : Data(data), pNext(NULL) {}
};
private:
// the head pointer of the stack
StackNode* m_pTop;
public:
Stack();
~Stack();
/// <summary>
/// push the data into this stack
/// </summary>
///
/// <param name="data">
/// a data to push into this stack
/// </param>
void Push(T data);
/// <summary>
/// pop(remove) the last-in data from this stack
/// </summary>
void Pop();
/// <summary>
/// get the last-in data of this stack
/// </summary>
///
/// <returns>
/// the last-in data of this stack
/// </returns>
T Top();
/// <summary>
/// check whether this stack is empty or not.
/// </summary>
///
/// <returns>
/// true if this stack is empty.
/// false otherwise.
/// </returns>
bool IsEmpty();
};
#endif