-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
60 lines (48 loc) · 1.1 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
#include "types.h"
namespace amps
{
class gstack
{
objects stack_;
public:
gstack() = default;
gstack(const gstack&) = delete;
gstack(gstack&&) = delete;
~gstack() = default;
gstack operator=(const gstack&) = delete;
gstack operator=(gstack&&) = delete;
object pop();
object look_back() const;
void push(object_t value);
void clear();
bool empty() const;
};
inline void gstack::push(object_t value)
{
stack_.emplace_back(value);
}
inline object gstack::pop()
{
if (empty()) {
return {};
}
object_t value = stack_.back();
stack_.pop_back();
return value;
}
inline object gstack::look_back() const
{
return stack_.back();
}
inline bool gstack::empty() const
{
return stack_.size() == 0;
}
inline void gstack::clear()
{
stack_.clear();
}
}
#endif // STACK_H