-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
62 lines (51 loc) · 1.1 KB
/
stack.h
File metadata and controls
62 lines (51 loc) · 1.1 KB
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
61
62
#include <list>
#include <vector>
using namespace std;
class IStack {
//Adauga element
virtual void push(int elem) = 0; //Scoate element din varf
virtual void pop() = 0;
//Returneaza elementul din varf
virtual int top() = 0;
//Returneaza true daca stiva e goala
virtual bool isEmpty() = 0;
};
#ifdef VECTOR_BASED_STACK
class Stack : public IStack {
/*
TODO implementati o stiva bazata pe un vector
Folositi clasa vector. Metodele de care aveti nevoie sunt
back, push_back, pop_back si empty
Aveti grija sa eliberati memoria pentru vector in destructor
*/
vector<int> st;
public:
void push(int elem) {
}
void pop() {
}
int top() {
}
bool isEmpty() {
}
};
#else
class Stack : public IStack {
/*
TODO implementati o stiva folosind o lista
Folositi lista pusa la dispozitie.
Metodele de care aveti nevoie sunt back, push_back,
pop_back si empty
*/
list<int> st;
public:
void push(int elem) {
}
void pop() {
}
int top() {
}
bool isEmpty() {
}
};
#endif