-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
88 lines (70 loc) · 2.16 KB
/
Source.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
#include <iostream>
#include <algorithm>
#include "Tests.h"
#include "Number.h"
#include "Map.h"
#include "File.h"
#include <bitset>
#include <string>
template <typename TSequance>
void ShowSequaence(const TSequance& obj, char separator = ' ')
{
for (auto s : obj)
{
std::cout << s << separator;
}
std::cout << std::endl;
}
int main()
{
Number<unsigned int> n(123);
ShowSequaence(n);
Number<unsigned int>::iterator itemN = std::find(n.begin(), n.end(), (bool)1);
std::cout << *itemN << std::endl;
*itemN = !*itemN;
std::cout << "Found: " << *itemN << std::endl;
Number<unsigned int>::filter_iterator filtIter = n.filter([](bool obj)
{
return obj == 0 ? false : true;
});
std::cout << *filtIter++ << std::endl;
std::cout << *filtIter++ << std::endl;
std::cout << *filtIter++ << std::endl;
std::cout << *filtIter << std::endl;
std::bitset<32> b(123);
std::bitset<32>::reference& r = b[1];
r = !r;
std::cout << b.to_ulong() << std::endl;
std::cout << "==================MAP==============\n";
Map<Region<int> > m;
m.addRegion(Region<int>("LA", Coords<int>(34, -118)));
m.addRegion(Region<int>("LA1", Coords<int>(1, 18)));
m.addRegion(Region<int>("LA2", Coords<int>(2, -118)));
m.addRegion(Region<int>("LA3", Coords<int>(3, -118)));
ShowSequaence(m);
Region<int> toFind("LA1", Coords<int>(1, 18));
Map<Region<int> >::iterator itemM = std::find(m.begin(), m.end(), toFind);
std::cout << "Found: " << *itemM << std::endl;
Map<Region<int> >::filter_iterator filtMapIter =
m.filter([](Region<int> obj)
{
return obj.name == "LA1" ? false : true;
});
std::cout << *filtMapIter++ << std::endl;
std::cout << *filtMapIter++ << std::endl;
std::cout << *filtMapIter++ << std::endl;
std::cout << "==================FILE==============\n";
File f("text.txt");
ShowSequaence(f, '\n');
File::iterator itemF = std::find(f.begin(), f.end(), "3.black");
std::cout << "Found: " << *itemF << std::endl;
File::filter_iterator filtFileIter =
f.filter([](line obj)
{
return obj == "4.red" ? false : true;
});
std::cout << *filtFileIter++ << std::endl;
std::cout << *filtFileIter++ << std::endl;
std::cout << *filtFileIter++ << std::endl;
return 0;
}