-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack3_as_vector1.hh
49 lines (37 loc) · 972 Bytes
/
stack3_as_vector1.hh
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
/**
* Task 3.1 from Cracking Coding Interview
*
* We are going to use vector and extend it's size as stacks are growing
*/
#ifndef ALGORITHMS_STACK3_AS_VECTOR
#define ALGORITHMS_STACK3_AS_VECTOR
#include <vector>
#include <stdexcept>
namespace Algorithms {
class Stack3 {
#define INIT_CAPACITY 6
std::vector<int> vect;
int s1_start = 0, s1_curr = 0, s1_end = 2;
int s2_start = 2, s2_curr = 2, s2_end = 4;
int s3_start = 4, s3_curr = 4, s3_end = 6;
std::vector<int> copy(int cap1, int cap2, int cap3);
void resize1();
void resize2();
void resize3();
public:
Stack3();
void push1(int num);
void push2(int num);
void push3(int num);
int pop1();
int pop2();
int pop3();
int size1();
int size2();
int size3();
int capacity1();
int capacity2();
int capacity3();
};
}
#endif