17 template <
typename A,
typename B>
18 std::vector<std::pair<A, B>>
19 zip(
const std::vector<A>& as,
const std::vector<B>& bs)
21 std::vector<std::pair<A, B>> ret;
22 const auto s =
std::min(as.size(), bs.size());
23 for(std::size_t index = 0; index < s; index += 1)
25 ret.emplace_back(std::make_pair<A, B>(as[index], bs[index]));
31 template <
typename A,
typename B>
32 std::vector<std::pair<A, B>>
35 const std::vector<A>& as,
36 const std::vector<B>& bs,
41 std::vector<std::pair<A, B>> ret;
42 const auto s =
std::max(as.size(), bs.size());
43 for(std::size_t index = 0; index < s; index += 1)
45 const A a = index < as.size() ? as[index] : da;
46 const B b = index < bs.size() ? bs[index] : db;
47 ret.emplace_back(a, b);
54 template <
typename T,
typename F = T,
typename C>
56 map(
const std::vector<F>& fs, C convert)
60 for(
const auto& f: fs)
62 r.emplace_back(convert(f));
68 template <
typename T,
typename K,
typename V,
typename C>
70 map(
const std::map<K, V>& fs, C convert)
76 r.emplace_back(convert(f.first, f.second));
84 template <
typename T,
typename C>
86 filter(
const std::vector<T>& ts, C check)
103 template <
typename T,
typename C>
105 all(
const std::vector<T>& ts, C check)
108 r.reserve(ts.size());
109 for(
const auto t: ts)
120 template <
typename T,
typename C>
122 any(
const std::vector<T>& ts, C check)
125 r.reserve(ts.size());
126 for(
const auto t: ts)
145 template <
typename T,
typename R = T,
typename C>
147 fold(
const std::vector<T>& ts, C concat, R zero)
150 for(
const auto& t: ts)
R fold(const std::vector< T > &ts, C concat, R zero)
std::vector< std::pair< A, B > > zip_longest(const std::vector< A > &as, const std::vector< B > &bs, A da=A(), B db=B())
bool all(const std::vector< T > &ts, C check)
std::vector< T > map(const std::vector< F > &fs, C convert)
std::vector< std::pair< A, B > > zip(const std::vector< A > &as, const std::vector< B > &bs)
size2f min(const size2f lhs, const size2f rhs)
size2f max(const size2f lhs, const size2f rhs)
bool any(const std::vector< T > &ts, C check)
std::vector< T > filter(const std::vector< T > &ts, C check)