-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.elist.cpp
67 lines (49 loc) · 2.05 KB
/
test.elist.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
#include "elist.hpp"
#include "prettyprint.hpp"
#include <iostream>
#include <list>
int main(int argc, char** argv){
std::list<int> l;
ehtesh::list el;
static const int TOTAL_SIZE = 1e2;
for (int i=0; i<TOTAL_SIZE; i++){
el.push_back(i);
}
auto l_it = l.begin();
ehtesh::list::iterator el_it = el.begin();
ehtesh::list::iterator el_it_other = el.begin();
std::cout << "std::list::iterator<int>:" << *l_it << std::endl;
std::cout << "ehtesh::list::iterator:" << *el_it << std::endl;
std::cout << "ehtesh::list::iterator.operator==()" << (el_it == el_it_other) << std::endl; // true
el_it_other++;
std::cout << "ehtesh::list::iterator.operator==()" << (el_it == el_it_other) << std::endl; // false
std::cout << "ehtesh::list::iterator.operator==()" << (++el_it == el_it_other) << std::endl; // true
std::cout << "ehtesh::list::iterator.operator==()" << (el_it == el_it_other++) << std::endl; // true
std::cout << "ehtesh::list::iterator.operator==()" << (el_it == el_it_other) << std::endl; // false
std::cout << "ehtesh::list::iterator.operator==()" << (el_it == el_it_other--) << std::endl; // false
std::cout << "ehtesh::list::iterator.operator==()" << (el_it == el_it_other) << std::endl; // true
std::cout << "ehtesh::list::iterator.operator==()" << (--el_it == el_it_other) << std::endl; // false
for (auto i : el) {
std::cout << i << std::endl;
}
std::cout << "push_back():" << el << std::endl;
el.resize(TOTAL_SIZE * 2);
std::cout << "resize():" << el << std::endl;
for (int i=0; i<TOTAL_SIZE; i++){
el.pop_back();
}
std::cout << "pop_back():" << el << std::endl;
for (int i=0; i<TOTAL_SIZE; i++){
el.pop_front();
}
std::cout << "pop_front():" << el << std::endl;
for (int i=0; i<TOTAL_SIZE; i++){
el.push_front(i);
}
std::cout << "push_front():" << el << std::endl;
for (int i=0; i<TOTAL_SIZE; i++){
el.pop_front();
}
std::cout << "pop_front():" << el << std::endl;
return 0;
}