-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack_main.cpp
71 lines (62 loc) · 2.49 KB
/
stack_main.cpp
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
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* stack_main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ayennoui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/01 14:48:53 by ayennoui #+# #+# */
/* Updated: 2021/03/01 15:36:56 by ayennoui ### ########.fr */
/* */
/* ************************************************************************** */
#include "stack/stack.hpp"
#include <stack>
int main()
{
ft::stack<int> x;
// empty
std::cout << "-------------- empty --------------" << std::endl;
std::cout << x.empty() << std::endl;
// size
std::cout << "-------------- size --------------" << std::endl;
std::cout << x.size() << std::endl;
// top
std::cout << "-------------- top --------------" << std::endl;
std::cout << x.top() << std::endl;
// push
std::cout << "-------------- push --------------" << std::endl;
x.push(0);
x.push(1);
x.push(3);
x.push(10);
std::cout << "size: " << x.size() << std::endl;
std::cout << "top: " << x.top() << std::endl;
// pop
std::cout << "-------------- pop --------------" << std::endl;
x.pop(); // pop 10
x.pop(); // pop 3
std::cout << "size: " << x.size() << std::endl;
std::cout << "top: " << x.top() << std::endl;
// relational operators (stack)
ft::stack<int> y;
ft::stack<int> z;
y.push(1);
z.push(1);
std::cout << "-------------- relational operators --------------" << std::endl;
if (y == z)
std::cout << "stack y and z are equal" << std::endl;
y.push(2);
if (y != z)
std::cout << "stack y and z are not equal" << std::endl;
if (y > z)
std::cout << "stack y is bigger than z" << std::endl;
if (y >= z)
std::cout << "stack y is bigger or equal to z" << std::endl;
y.pop();
y.pop();
if (y < z)
std::cout << "stack y is less than z" << std::endl;
if (y <= z)
std::cout << "stack y is less or equal to z" << std::endl;
return (0);
}