-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
48 lines (32 loc) · 1.36 KB
/
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
#include <iostream>
#include <functional>
#include <vector>
#include <memory>
#include "include/languageStyleIterator/cppIterators.h"
#include "include/functionalIterator.h"
int main() {
std::vector<int> test{1,3,5};
std::vector<int> test2{1,2,3,4,5,6,7,8};
//auto beg = Iterator<int, std::vector<int>::iterator>(test.begin());
//auto en = Iterator<int, std::vector<int>::iterator>(test.end());
// MapIterator<int, std::string, std::vector<int>::iterator> mi{};
cpp::VectorIterable<int> it{test};
std::shared_ptr<java::Iterator<int>> l = it.shared_iterator();
cpp::VectorIterable<int> it2{test2};
std::shared_ptr<java::Iterator<int>> m = it2.shared_iterator();
// Chaining all the vectors into one single iteration
functional::Join<int> j{};
java::Iterator<int>* join = (j >> l >> m).done();
//java::Iterator<int>* join = ((new functional::Unnest<int>())->add(it.iterator()))->add(it2.iterator())->quit();
// Mapping all the numbers into something else
java::Iterator<int>* fmap = new functional::MapIterator<int,int>(join, [](int k){return k+3;});
// Filtering the elements
java::Iterator<int>* mpi = new functional::FilterIterator<int>(fmap, [](int k){return k % 2;});
// Final iteration
while (mpi->hasNext()) {
std::cout << mpi->next() << std::endl;
}
delete mpi;
delete fmap;
return 0;
}