-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathValueStack.h
More file actions
33 lines (27 loc) · 924 Bytes
/
ValueStack.h
File metadata and controls
33 lines (27 loc) · 924 Bytes
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
#ifndef VALUE_STACK
#define VALUE_STACK
#include <list>
#include <assert.h>
#include "Value.h"
class ValueStack {
protected:
std::list<Value> valueStack;
public:
bool isEmpty() const {return valueStack.empty();}
void clear() {valueStack.clear();}
void push(const Value& v){valueStack.push_front(v);}
void pop() {assert(!isEmpty()); valueStack.pop_front();}
int size(){return valueStack.size();}
const Value& top() const {assert(!isEmpty()); return valueStack.front();}
unsigned size() const {return valueStack.size();}
const Value getTopAndPop() {
assert(!isEmpty());
auto v = valueStack.front();
valueStack.pop_front();
return v;
}
ValueStack() = default;
ValueStack(const ValueStack&) = delete;
ValueStack(ValueStack&&) = delete;
};
#endif