-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_stack.cpp
105 lines (94 loc) · 2.73 KB
/
main_stack.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main_stack.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbari <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/22 22:51:30 by mbari #+# #+# */
#include <string>
#include <deque>
#include "containers/stack/stack.hpp"
#include <stack>
#include <stdlib.h>
#ifndef PH
#define PH ft
#endif
#define COUNT (MAX_RAM / (int)sizeof(Buffer))
template<typename T>
class MutantStack : public PH::stack<T>
{
public:
MutantStack() {std::cout << "====================\n";}
MutantStack(const MutantStack<T>& src) { *this = src; }
MutantStack<T>& operator=(const MutantStack<T>& rhs)
{
this->c = rhs.c;
return *this;
}
~MutantStack() {}
typedef typename PH::stack<T>::container_type::iterator iterator;
iterator begin() { return this->c.begin(); }
iterator end() { return this->c.end(); }
};
int main()
{
{
PH::stack<int> stack_int;
MutantStack<char> iterable_stack;
for (char letter = 'a'; letter <= 'z'; letter++)
iterable_stack.push(letter);
for (MutantStack<char>::iterator it = iterable_stack.begin(); it != iterable_stack.end(); it++)
{
std::cout << *it;
}
}
std::cout << std::endl;
{
try
{
std::cout << "========== OG ==========" << std::endl;
std::stack<int> st;
std::stack<int> st2;
std::cout << st.empty() << std::endl;
std::cout << st.size() << std::endl;
st.push(10);
std::cout << st.top() << std::endl;
st.push(20);
std::cout << st.top() << std::endl;
st.pop();
std::cout << st.top() << std::endl;
std::cout << st.empty() << std::endl;
std::cout << st.size() << std::endl;
std::cout << "comp : " << (st == st2) << std::endl;
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
}
}
{
try
{
std::cout << "========== MINE ==========" << std::endl;
ft::stack<int> st;
ft::stack<int> st2;
std::cout << st.empty() << std::endl;
std::cout << st.size() << std::endl;
st.push(10);
std::cout << st.top() << std::endl;
st.push(20);
std::cout << st.top() << std::endl;
st.pop();
std::cout << st.top() << std::endl;
std::cout << st.empty() << std::endl;
std::cout << st.size() << std::endl;
std::cout << "comp : " << (st == st2) << std::endl;
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
}
}
return (0);
}