forked from ryanhaining/cppitertools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcommand_chains.cpp
More file actions
65 lines (61 loc) · 1.75 KB
/
Copy pathtestcommand_chains.cpp
File metadata and controls
65 lines (61 loc) · 1.75 KB
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
#include <itertools.hpp>
#include <vector>
#include <tuple>
#include <array>
#include <iostream>
#include <string>
using namespace iter;
template <typename T>
std::ostream & operator<<(std::ostream & o, const boost::optional<T> & opt) {
if (opt) {
std::cout << *opt;
}
else {
std::cout << "Object disengaged of type " << typeid(T).name();
}
return o;
}
int main() {
{
std::vector<int> vec1{1,2,3,4,5,6};
std::vector<int> vec2{1,2,3,4,5};
std::vector<std::string> strvec
{"his","name","was","robert","paulson","his","name","was","robert","paulson"};
for (auto t : zip_longest(chain(vec1,vec2),strvec)) {
std::cout << std::get<0>(t) << " "
<< std::get<1>(t) << std::endl;
}
}
std::cout << std::endl;
/*
{
std::vector<int> vec1{1,2,3,4,5,6};
std::vector<int> vec2{7,8,9,10};
std::vector<std::string> strvec
{"We're","done","when","I","say","we're","done"};
for (auto t : zip(strvec,chain(slice(vec1,2,6),slice(vec2,1,4)))) {
std::cout << std::get<0>(t) << " "
<< std::get<1>(t) << std::endl;
}
}
*/
std::cout << std::endl;
{
std::vector<int> vec1{1,2,3,4,5,6};
std::vector<int> vec2{7,8,9,10};
for (auto s : sliding_window(chain(vec1,vec2),4)) {
for (auto i : s) std::cout << i << " ";
std::cout<<std::endl;
}
}
std::cout << std::endl;
{
std::vector<int> vec1{1,2,3,4,5,6};
std::vector<int> vec2{7,8,9,10};
for (auto s : grouper(chain(vec1,vec2),3)) {
for (auto i : s) std::cout << i << " ";
std::cout<<std::endl;
}
}
return 0;
}