Debian Codegraph @

src/librssguard/3rd-party/boolinq/boolinq.h

raw symbols SCIP
1 #cxx . . $ `<file>/src/librssguard/3rd-party/boolinq/boolinq.h`/pragma once
2
3 #include <limits.h>
4
5 #include <functional>
6 #include <tuple>
7
8 #include <algorithm>
9 #include <deque>
10 #include <iostream>
11 #include <iterator>
12 #include <list>
13 #include <set>
14 #include <unordered_set>
15 #include <vector>
16
17 //
18
19 namespace boolinqcxx . . $ boolinq/ {
20
21 struct LinqEndExceptioncxx . . $ boolinq/LinqEndException# {};
22
23 enum BytesDirectioncxx . . $ boolinq/BytesDirection# {
24 BytesFirstToLastcxx . . $ boolinq/BytesFirstToLast.,
25 BytesLastToFirstcxx . . $ boolinq/BytesLastToFirst.,
26 };
27
28 enum BitsDirectioncxx . . $ boolinq/BitsDirection# {
29 BitsHighToLowcxx . . $ boolinq/BitsHighToLow.,
30 BitsLowToHighcxx . . $ boolinq/BitsLowToHigh.,
31 };
32
33 template<typename S, typename T>
34 class Linqcxx . . $ boolinq/Linq# {
35 stdcxx . . $ std/::functioncxx . . $ std/function#<T(S&)> nextFunccxx . . $ boolinq/Linq#nextFunc.;
36 S storagecxx . . $ boolinq/Linq#storage.;
37
38 public:
39 typedef T value_typecxx . . $ boolinq/Linq#value_type#;
40
41 Linqcxx . . $ boolinq/Linq#`Linq<S, T>`(49f6e7a06ebc5aa8).() : nextFunccxx . . $ boolinq/Linq#nextFunc.(), storagecxx . . $ boolinq/Linq#storage.()
42 {}
43
44 Linqcxx . . $ boolinq/Linq#`Linq<S, T>`(670de56d552e465f).(S storage, stdcxx . . $ std/::functioncxx . . $ std/function#<T(S&)> nextFunc) : nextFunccxx . . $ boolinq/Linq#nextFunc.(nextFunc), storagecxx . . $ boolinq/Linq#storage.(storage)
45 {}
46
47 T nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).()
48 {
49 return nextFunccxx . . $ boolinq/Linq#nextFunc.(storagecxx . . $ boolinq/Linq#storage.);
50 }
51
52 void for_each_icxx . . $ boolinq/Linq#for_each_i(711226a20dcdb4f8).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(T, int)> apply) const
53 {
54 Linqcxx . . $ boolinq/Linq#<S, T> linq = *this;
55
56 try {
57 for (int i = 0; ; i++) {
58 apply(linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).(), i);
59 }
60 }
61 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
62 }
63
64 void for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).(stdcxx . . $ std/::functioncxx . . $ std/function#<void(T)> apply) const
65 {
66 return for_each_icxx . . $ boolinq/Linq#for_each_i(711226a20dcdb4f8).([apply](T value, int) {
67 return apply(value);
68 });
69 }
70
71 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> where_icxx . . $ boolinq/Linq#where_i(67a3b16bf0cb8b62).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T, int)> filter) const
72 {
73 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T>(
74 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, 0),
75 [filter](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>& tuple) {
76 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(317e1dd7c6ae599).<0>(tuple);
77 int& index = stdcxx . . $ std/::getcxx . . $ std/get(5d08af03bc507121).<1>(tuple);
78
79 while (true) {
80 T ret = linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
81 if (filter(ret, index++)) {
82 return ret;
83 }
84 }
85 }
86 );
87 }
88
89 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> filter) const
90 {
91 return where_icxx . . $ boolinq/Linq#where_i(67a3b16bf0cb8b62).([filter](T value, int) {
92 return filter(value);
93 });
94 }
95
96 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> takecxx . . $ boolinq/Linq#take(c8bc196804ecde45).(int count) const
97 {
98 return where_icxx . . $ boolinq/Linq#where_i(67a3b16bf0cb8b62).([count](T /*value*/, int i) {
99 if (i == count) {
100 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
101 }
102
103 return true;
104 });
105 }
106
107 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> takeWhile_icxx . . $ boolinq/Linq#takeWhile_i(67a3b16bf0cb8b62).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T, int)> predicate) const
108 {
109 return where_icxx . . $ boolinq/Linq#where_i(67a3b16bf0cb8b62).([predicate](T value, int i) {
110 if (!predicate(value, i)) {
111 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
112 }
113
114 return true;
115 });
116 }
117
118 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> takeWhilecxx . . $ boolinq/Linq#takeWhile(d169c8e6e9294137).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
119 {
120 return takeWhile_icxx . . $ boolinq/Linq#takeWhile_i(67a3b16bf0cb8b62).([predicate](T value, int /*i*/) {
121 return predicate(value);
122 });
123 }
124
125 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> skipcxx . . $ boolinq/Linq#skip(c8bc196804ecde45).(int count) const
126 {
127 return where_icxx . . $ boolinq/Linq#where_i(67a3b16bf0cb8b62).([count](T, int i) {
128 return i >= count;
129 });
130 }
131
132 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int, bool>, T> skipWhile_icxx . . $ boolinq/Linq#skipWhile_i(d4470f6aef8c366a).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T, int)> predicate) const
133 {
134 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int, bool>, T>(
135 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, 0, false),
136 [predicate](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int, bool>& tuple) {
137 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(70afc5746c4001b1).<0>(tuple);
138 int& index = stdcxx . . $ std/::getcxx . . $ std/get(2b8af70fa318720a).<1>(tuple);
139 bool& flag = stdcxx . . $ std/::getcxx . . $ std/get(3745fbf9a4df67d6).<2>(tuple);
140
141 if (flag) {
142 return linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
143 }
144
145 while (true) {
146 T ret = linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
147 if (!predicate(ret, index++)) {
148 flag = true;
149 return ret;
150 }
151 }
152 }
153 );
154 }
155
156 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int, bool>, T> skipWhilecxx . . $ boolinq/Linq#skipWhile(3af836a1e12ff1ae).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
157 {
158 return skipWhile_icxx . . $ boolinq/Linq#skipWhile_i(d4470f6aef8c366a).([predicate](T value, int /*i*/) {
159 return predicate(value);
160 });
161 }
162
163 template<typename ... Types>
164 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, int>, T> appendcxx . . $ boolinq/Linq#append(3af7a51c50075849).(Types ... newValues) const
165 {
166 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, int>, T>(
167 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>{ newValues ... }, -1),
168 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, int>& tuple) {
169 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(317e1dd7c6ae599).<0>(tuple);
170 stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>& values = stdcxx . . $ std/::getcxx . . $ std/get(5aabc72a970aa7ce).<1>(tuple);
171 int& index = stdcxx . . $ std/::getcxx . . $ std/get(be89c998c264c45d).<2>(tuple);
172
173 if (index == -1) {
174 try {
175 return linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
176 }
177 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {
178 index = 0;
179 }
180 }
181
182 if (index < values.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()) {
183 return values[index++];
184 }
185
186 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
187 }
188 );
189 }
190
191 template<typename ... Types>
192 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, int>, T> prependcxx . . $ boolinq/Linq#prepend(3af7a51c50075849).(Types ... newValues) const
193 {
194 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, int>, T>(
195 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>{ newValues ... }, 0),
196 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, int>& tuple) {
197 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(2b8af70fa318720a).<0>(tuple);
198 stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>& values = stdcxx . . $ std/::getcxx . . $ std/get(3745fbf9a4df67d6).<1>(tuple);
199 int& index = stdcxx . . $ std/::getcxx . . $ std/get(607352554f49d4b5).<2>(tuple);
200
201 if (index < values.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()) {
202 return values[index++];
203 }
204
205 return linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
206 }
207 );
208 }
209
210 template<typename F, typename _TRet = typename stdcxx . . $ std/::result_of<F(T, int)>::type>
211 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, _TRet> select_icxx . . $ boolinq/Linq#select_i(a3f5bd4cd382e0ee).(F apply) const
212 {
213 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, _TRet>(
214 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, 0),
215 [apply](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>& tuple) {
216 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(58f9000eff7414f2).<0>(tuple);
217 int& index = stdcxx . . $ std/::getcxx . . $ std/get(3745fbf9a4df67d6).<1>(tuple);
218
219 return apply(linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).(), index++);
220 }
221 );
222 }
223
224 template<typename F, typename _TRet = typename stdcxx . . $ std/::result_of<F(T)>::type>
225 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, _TRet> selectcxx . . $ boolinq/Linq#select(a3f5bd4cd382e0ee).(F apply) const
226 {
227 return select_icxx . . $ boolinq/Linq#select_i(a3f5bd4cd382e0ee).([apply](T value, int /*index*/) {
228 return apply(value);
229 });
230 }
231
232 template<typename TRet>
233 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, TRet> castcxx . . $ boolinq/Linq#cast(bd84bb0edb38c57).() const
234 {
235 return select_icxx . . $ boolinq/Linq#select_i(a3f5bd4cd382e0ee).([](T value, int /*i*/) {
236 return TRet(value);
237 });
238 }
239
240 template<typename S2, typename T2>
241 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, Linqcxx . . $ boolinq/Linq#<S2, T2>, bool>, T> concatcxx . . $ boolinq/Linq#concat(c6d57b9bf715b63e).(const Linqcxx . . $ boolinq/Linq#<S2, T2>& rhs) const
242 {
243 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, Linqcxx . . $ boolinq/Linq#<S2, T2>, bool>, T>(
244 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, rhs, false),
245 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, Linqcxx . . $ boolinq/Linq#<S2, T2>, bool>& tuple) {
246 Linqcxx . . $ boolinq/Linq#<S, T>& first = stdcxx . . $ std/::getcxx . . $ std/get(5aabc72a970aa7ce).<0>(tuple);
247 Linqcxx . . $ boolinq/Linq#<S2, T2>& second = stdcxx . . $ std/::getcxx . . $ std/get(70afc5746c4001b1).<1>(tuple);
248 bool& flag = stdcxx . . $ std/::getcxx . . $ std/get(b5bb845d0107ee72).<2>(tuple);
249
250 if (!flag) {
251 try {
252 return first.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
253 }
254 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
255 }
256
257 return second.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
258 }
259 );
260 }
261
262 template<
263 typename F,
264 typename _TRet = typename stdcxx . . $ std/::result_of<F(T, int)>::type,
265 typename _TRetVal = typename _TRet::value_type
266 >
267 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, _TRet, int, bool>, _TRetVal> selectMany_icxx . . $ boolinq/Linq#selectMany_i(f59e0c7963495970).(F apply) const
268 {
269 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, _TRet, int, bool>, _TRetVal>(
270 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, _TRet(), 0, true),
271 [apply](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, _TRet, int, bool>& tuple) {
272 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(5aabc72a970aa7ce).<0>(tuple);
273 _TRet& current = stdcxx . . $ std/::getcxx . . $ std/get(9a1b01079da03411).<1>(tuple);
274 int& index = stdcxx . . $ std/::getcxx . . $ std/get(2b8af70fa318720a).<2>(tuple);
275 bool& finished = stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<3>(tuple);
276
277 while (true) {
278 if (finished) {
279 current = apply(linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).(), index++);
280 finished = false;
281 }
282
283 try {
284 return current.next();
285 }
286 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {
287 finished = true;
288 }
289 }
290 }
291 );
292 }
293
294 template<
295 typename F,
296 typename _TRet = typename stdcxx . . $ std/::result_of<F(T)>::type,
297 typename _TRetVal = typename _TRet::value_type
298 >
299 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, _TRet, int, bool>, _TRetVal> selectManycxx . . $ boolinq/Linq#selectMany(f59e0c7963495970).(F apply) const
300 {
301 return selectMany_icxx . . $ boolinq/Linq#selectMany_i(f59e0c7963495970).([apply](T value, int) {
302 return apply(value);
303 });
304 }
305
306 template<
307 typename F,
308 typename _TKey = typename stdcxx . . $ std/::result_of<F(T)>::type,
309 typename _TValue = Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, int>, T> // where(predicate)
310 >
311 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TKey>>, stdcxx . . $ std/::paircxx . . $ std/pair#<_TKey, _TValue>> groupBycxx . . $ boolinq/Linq#groupBy(913e82e8951340e4).(F apply) const
312 {
313 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TKey>>, stdcxx . . $ std/::paircxx . . $ std/pair#<_TKey, _TValue>>(
314 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, *this, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TKey>()),
315 [apply](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TKey>>& tuple) {
316 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(317e1dd7c6ae599).<0>(tuple);
317 Linqcxx . . $ boolinq/Linq#<S, T>& linqCopy = stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<1>(tuple);
318 stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TKey>& set = stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<2>(tuple);
319
320 while (true) {
321 _TKey key = apply(linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).());
322 if (set.insertcxx . . $ std/unordered_set#insert(f4888883da24e699).(key).second) {
323 return stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(key, linqCopy.wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).([apply, key](T v) {
324 return apply(v) ==cxx . . $ `operator==`(e06d507c3174a850). key;
325 }));
326 }
327 }
328 }
329 );
330 }
331
332 template<typename F, typename _TRet = typename stdcxx . . $ std/::result_of<F(T)>::type>
333 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TRet>>, T> distinctcxx . . $ boolinq/Linq#distinct(941dd66fbd4d8cc5).(F transform) const
334 {
335 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TRet>>, T>(
336 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TRet>()),
337 [transform](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TRet>>& tuple) {
338 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(be89c998c264c45d).<0>(tuple);
339 stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<_TRet>& set = stdcxx . . $ std/::getcxx . . $ std/get(6c68b51b79f97de2).<1>(tuple);
340
341 while (true) {
342 T value = linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
343 if (set.insertcxx . . $ std/unordered_set#insert(50ef72ff69bc573d).(transform(value)).second) {
344 return value;
345 }
346 }
347 }
348 );
349 }
350
351 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<T>>, T> distinctcxx . . $ boolinq/Linq#distinct(58d30379f29c1b96).() const
352 {
353 return distinctcxx . . $ boolinq/Linq#distinct(941dd66fbd4d8cc5).([](T value) {
354 return value;
355 });
356 }
357
358 template<typename F, typename _TIter = typename stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>::const_iterator>
359 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, _TIter, bool>, T> orderBycxx . . $ boolinq/Linq#orderBy(994903f26a0091c3).(F transform) const
360 {
361 stdcxx . . $ std/::vectorcxx . . $ std/vector#<T> items = toStdVectorcxx . . $ boolinq/Linq#toStdVector(385d4323d7ff3cb0).();
362
363 stdcxx . . $ std/::sortcxx . . $ std/sort(360855cc766c4ee5).(items.begincxx . . $ std/vector#begin(55a6de06420d4903).(), items.endcxx . . $ std/vector#end(55a6de06420d4903).(), [transform](const T& a, const T& b) {
364 return transform(a) < transform(b);
365 });
366
367 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, _TIter, bool>, T>(
368 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(items, _TIter(), false),
369 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, _TIter, bool>& tuple) {
370 stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>& vec = stdcxx . . $ std/::getcxx . . $ std/get(70afc5746c4001b1).<0>(tuple);
371 _TIter& it = stdcxx . . $ std/::getcxx . . $ std/get(51b66c851421c132).<1>(tuple);
372 bool& flag = stdcxx . . $ std/::getcxx . . $ std/get(607352554f49d4b5).<2>(tuple);
373
374 if (!flag) {
375 flag = true;
376 it = vec.cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).();
377 }
378
379 if (it ==cxx . . $ `operator==`(dc37b9a333022f1a). vec.cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).()) {
380 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
381 }
382
383 return *cxx . . $ `operator*`(669912fdaa6a85b8).(it++);
384 }
385 );
386 }
387
388 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>, typename stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>::const_iterator, bool>, T> orderBycxx . . $ boolinq/Linq#orderBy(ee460a6c9795c07b).() const
389 {
390 return orderBycxx . . $ boolinq/Linq#orderBy(ee460a6c9795c07b).([](T value) {
391 return value;
392 });
393 }
394
395 template<typename _TIter = typename stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T>::const_reverse_iterator>
396 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T>, _TIter, bool>, T> reversecxx . . $ boolinq/Linq#reverse(11d9c7e2c5da1929).() const
397 {
398 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T>, _TIter, bool>, T>(
399 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(toStdListcxx . . $ boolinq/Linq#toStdList(2989115be80c3067).(), _TIter(), false),
400 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T>, _TIter, bool>& tuple) {
401 stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T>& list = stdcxx . . $ std/::getcxx . . $ std/get(be89c998c264c45d).<0>(tuple);
402 _TIter& it = stdcxx . . $ std/::getcxx . . $ std/get(3745fbf9a4df67d6).<1>(tuple);
403 bool& flag = stdcxx . . $ std/::getcxx . . $ std/get(70afc5746c4001b1).<2>(tuple);
404
405 if (!flag) {
406 flag = true;
407 it = list.crbegincxx . . $ std/__cxx11/list#crbegin(3b28a09d3e394fce).();
408 }
409
410 if (it ==cxx . . $ `operator==`(dc37b9a333022f1a). list.crendcxx . . $ std/__cxx11/list#crend(3b28a09d3e394fce).()) {
411 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
412 }
413
414 return *cxx . . $ `operator*`(4374dbcd7a386365).(it++);
415 }
416 );
417 }
418
419 // Aggregators
420
421 template<typename TRet>
422 TRet aggregatecxx . . $ boolinq/Linq#aggregate(d4c686cabc0a78e5).(TRet start, stdcxx . . $ std/::functioncxx . . $ std/function#<TRet(TRet, T)> accumulate) const
423 {
424 Linqcxx . . $ boolinq/Linq#<S, T> linq = *this;
425
426 try {
427 while (true) {
428 start = accumulate(start, linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).());
429 }
430 }
431 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
432
433 return start;
434 }
435
436 template<typename F, typename _TRet = typename stdcxx . . $ std/::result_of<F(T)>::type>
437 _TRet sumcxx . . $ boolinq/Linq#sum(5f5339430a5d2cc6).(F transform) const
438 {
439 return aggregatecxx . . $ boolinq/Linq#aggregate(d4c686cabc0a78e5).<_TRet>(_TRet(), [transform](_TRet accumulator, T value) {
440 return accumulator +cxx . . $ operator+(cb7578368d318a2a). transform(value);
441 });
442 }
443
444 template<typename TRet = T>
445 TRet sumcxx . . $ boolinq/Linq#sum(900f63fbdad42e82).() const
446 {
447 return sumcxx . . $ boolinq/Linq#sum(900f63fbdad42e82).([](T value) {
448 return TRet(value);
449 });
450 }
451
452 template<typename F, typename _TRet = typename stdcxx . . $ std/::result_of<F(T)>::type>
453 _TRet avgcxx . . $ boolinq/Linq#avg(5f5339430a5d2cc6).(F transform) const
454 {
455 int count = 0;
456 _TRet res = sumcxx . . $ boolinq/Linq#sum(5f5339430a5d2cc6).([transform, &count](T value) {
457 count++;
458 return transform(value);
459 });
460
461 return res /cxx . . $ `operator/`(7ccba937cdf1804b). count;
462 }
463
464 template<typename TRet = T>
465 TRet avgcxx . . $ boolinq/Linq#avg(900f63fbdad42e82).() const
466 {
467 return avgcxx . . $ boolinq/Linq#avg(900f63fbdad42e82).([](T value) {
468 return TRet(value);
469 });
470 }
471
472 int countcxx . . $ boolinq/Linq#count(455f465bc33b4cdf).() const
473 {
474 int index = 0;
475
476 for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).([&index](T /*a*/) {
477 index++;
478 });
479 return index;
480 }
481
482 int countcxx . . $ boolinq/Linq#count(b0b36b02b8b625f5).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
483 {
484 return wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).(predicate).count();
485 }
486
487 int countcxx . . $ boolinq/Linq#count(b6e3495edf6d6c13).(const T& item) const
488 {
489 return countcxx . . $ boolinq/Linq#count(b6e3495edf6d6c13).([item](T value) {
490 return item ==cxx . . $ `operator==`(e06d507c3174a850). value;
491 });
492 }
493
494 // Bool aggregators
495
496 bool anycxx . . $ boolinq/Linq#any(992a0234366b9b4f).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
497 {
498 Linqcxx . . $ boolinq/Linq#<S, T> linq = *this;
499
500 try {
501 while (true) {
502 if (predicate(linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).()))
503 return true;
504 }
505 }
506 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
507
508 return false;
509 }
510
511 bool anycxx . . $ boolinq/Linq#any(50ce9a9e25b4a850).() const
512 {
513 return anycxx . . $ boolinq/Linq#any(992a0234366b9b4f).([](T value) {
514 return static_cast<bool>(value);
515 });
516 }
517
518 bool allcxx . . $ boolinq/Linq#all(992a0234366b9b4f).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
519 {
520 return !anycxx . . $ boolinq/Linq#any(50ce9a9e25b4a850).([predicate](T value) {
521 return !predicate(value);
522 });
523 }
524
525 bool allcxx . . $ boolinq/Linq#all(50ce9a9e25b4a850).() const
526 {
527 return allcxx . . $ boolinq/Linq#all(992a0234366b9b4f).([](T value) {
528 return static_cast<bool>(value);
529 });
530 }
531
532 bool containscxx . . $ boolinq/Linq#contains(83b2481dfe9844ed).(const T& item) const
533 {
534 return anycxx . . $ boolinq/Linq#any(50ce9a9e25b4a850).([&item](T value) {
535 return value ==cxx . . $ `operator==`(e06d507c3174a850). item;
536 });
537 }
538
539 // Election aggregators
540
541 T electcxx . . $ boolinq/Linq#elect(2b47f9228cf2aa92).(stdcxx . . $ std/::functioncxx . . $ std/function#<T(T, T)> accumulate) const
542 {
543 T result;
544
545 for_each_icxx . . $ boolinq/Linq#for_each_i(711226a20dcdb4f8).([accumulate, &result](T value, int i) {
546 if (i == 0) {
547 result = value;
548 }
549 else {
550 result = accumulate(result, value);
551 }
552 });
553 return result;
554 }
555
556 template<typename F>
557 T maxcxx . . $ boolinq/Linq#max(6ff2e32d256ea728).(F transform) const
558 {
559 return electcxx . . $ boolinq/Linq#elect(2b47f9228cf2aa92).([transform](const T& a, const T& b) {
560 return (transform(a) < transform(b)) ? b : a;
561 });
562 }
563
564 T maxcxx . . $ boolinq/Linq#max(7b7646ca7c721626).() const
565 {
566 return maxcxx . . $ boolinq/Linq#max(7b7646ca7c721626).([](T value) {
567 return value;
568 });
569 }
570
571 template<typename F>
572 T mincxx . . $ boolinq/Linq#min(6ff2e32d256ea728).(F transform) const
573 {
574 return electcxx . . $ boolinq/Linq#elect(2b47f9228cf2aa92).([transform](const T& a, const T& b) {
575 return (transform(a) < transform(b)) ? a : b;
576 });
577 }
578
579 T mincxx . . $ boolinq/Linq#min(7b7646ca7c721626).() const
580 {
581 return mincxx . . $ boolinq/Linq#min(6ff2e32d256ea728).([](T value) {
582 return value;
583 });
584 }
585
586 // Single object returners
587
588 T elementAtcxx . . $ boolinq/Linq#elementAt(d15e0de028588936).(int index) const
589 {
590 return skipcxx . . $ boolinq/Linq#skip(c8bc196804ecde45).(index).next();
591 }
592
593 T firstcxx . . $ boolinq/Linq#first(b3b4635b5093b302).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
594 {
595 return wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).(predicate).next();
596 }
597
598 T firstcxx . . $ boolinq/Linq#first(7b7646ca7c721626).() const
599 {
600 return Linqcxx . . $ boolinq/Linq#<S, T>(*this).nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
601 }
602
603 T firstOrDefaultcxx . . $ boolinq/Linq#firstOrDefault(72be2761f3eff290).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate, T const& defaultValue = T()) const
604 {
605 try {
606 return wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).(predicate).next();
607 }
608 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
609
610 return defaultValue;
611 }
612
613 T firstOrDefaultcxx . . $ boolinq/Linq#firstOrDefault(62d06648a23e3365).(T const& defaultValue = T()) const
614 {
615 try {
616 return Linqcxx . . $ boolinq/Linq#<S, T>(*this).nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
617 }
618 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
619
620 return defaultValue;
621 }
622
623 T lastcxx . . $ boolinq/Linq#last(b3b4635b5093b302).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate) const
624 {
625 T res;
626 int index = -1;
627
628 wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).(predicate).for_each_i([&res, &index](T value, int i) {
629 res = value;
630 index = i;
631 });
632
633 if (index == -1) {
634 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
635 }
636
637 return res;
638 }
639
640 T lastcxx . . $ boolinq/Linq#last(7b7646ca7c721626).() const
641 {
642 return lastcxx . . $ boolinq/Linq#last(b3b4635b5093b302).([](T /*value*/) {
643 return true;
644 });
645 }
646
647 T lastOrDefaultcxx . . $ boolinq/Linq#lastOrDefault(72be2761f3eff290).(stdcxx . . $ std/::functioncxx . . $ std/function#<bool(T)> predicate, T const& defaultValue = T()) const
648 {
649 T res = defaultValue;
650
651 wherecxx . . $ boolinq/Linq#where(d169c8e6e9294137).(predicate).for_each([&res](T value) {
652 res = value;
653 });
654 return res;
655 }
656
657 T lastOrDefaultcxx . . $ boolinq/Linq#lastOrDefault(62d06648a23e3365).(T const& defaultValue = T()) const
658 {
659 return lastOrDefaultcxx . . $ boolinq/Linq#lastOrDefault(72be2761f3eff290).([](T /*value*/) {
660 return true;
661 }, defaultValue);
662 }
663
664 // Export to containers
665
666 stdcxx . . $ std/::vectorcxx . . $ std/vector#<T> toStdVectorcxx . . $ boolinq/Linq#toStdVector(385d4323d7ff3cb0).() const
667 {
668 stdcxx . . $ std/::vectorcxx . . $ std/vector#<T> items;
669
670 for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).([&items](T value) {
671 items.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(value);
672 });
673 return items;
674 }
675
676 stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T> toStdListcxx . . $ boolinq/Linq#toStdList(2989115be80c3067).() const
677 {
678 stdcxx . . $ std/::listcxx . . $ std/__cxx11/list#<T> items;
679
680 for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).([&items](T value) {
681 items.push_backcxx . . $ std/__cxx11/list#push_back(77d9f17553126ecb).(value);
682 });
683 return items;
684 }
685
686 stdcxx . . $ std/::dequecxx . . $ std/deque#<T> toStdDequecxx . . $ boolinq/Linq#toStdDeque(689295bdbe80e2ad).() const
687 {
688 stdcxx . . $ std/::dequecxx . . $ std/deque#<T> items;
689
690 for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).([&items](T value) {
691 items.push_backcxx . . $ std/deque#push_back(fe7a8a4d1eddb70).(value);
692 });
693 return items;
694 }
695
696 stdcxx . . $ std/::setcxx . . $ std/set#<T> toStdSetcxx . . $ boolinq/Linq#toStdSet(654672dfb5f67824).() const
697 {
698 stdcxx . . $ std/::setcxx . . $ std/set#<T> items;
699
700 for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).([&items](T value) {
701 items.insertcxx . . $ std/set#insert(411a10a755068dfe).(value);
702 });
703 return items;
704 }
705
706 stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<T> toStdUnorderedSetcxx . . $ boolinq/Linq#toStdUnorderedSet(7c08be8833b29044).() const
707 {
708 stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<T> items;
709
710 for_eachcxx . . $ boolinq/Linq#for_each(66e864814bcd1933).([&items](T value) {
711 items.insertcxx . . $ std/unordered_set#insert(84f103c07cf3703).(value);
712 });
713 return items;
714 }
715
716 // Bits and bytes
717
718 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, T, int>, int> bytescxx . . $ boolinq/Linq#bytes(10b77abca6a99ab5).(BytesDirectioncxx . . $ boolinq/BytesDirection# direction = BytesFirstToLastcxx . . $ boolinq/BytesFirstToLast.) const
719 {
720 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, T, int>, int>(
721 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, direction, T(), sizeof(T)),
722 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, T, int>& tuple) {
723 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(959d1ca383d8d70e).<0>(tuple);
724 BytesDirectioncxx . . $ boolinq/BytesDirection#& bytesDirection = stdcxx . . $ std/::getcxx . . $ std/get(6c68b51b79f97de2).<1>(tuple);
725 T& value = stdcxx . . $ std/::getcxx . . $ std/get(85b7410325da9aa2).<2>(tuple);
726 int& index = stdcxx . . $ std/::getcxx . . $ std/get(2b8af70fa318720a).<3>(tuple);
727
728 if (index == sizeof(T)) {
729 value = linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
730 index = 0;
731 }
732
733 unsigned char* ptr = reinterpret_cast<unsigned char*>(&cxx . . $ `operator&`(d79d882ef3001c00).value);
734
735 int byteIndex = index;
736 if (bytesDirection == BytesLastToFirstcxx . . $ boolinq/BytesLastToFirst.) {
737 byteIndex = sizeof(T) - 1 - byteIndex;
738 }
739
740 index++;
741 return ptr[byteIndex];
742 }
743 );
744 }
745
746 template<typename TRet>
747 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, int>, TRet> unbytescxx . . $ boolinq/Linq#unbytes(d734e1e43df795d5).(BytesDirectioncxx . . $ boolinq/BytesDirection# direction = BytesFirstToLastcxx . . $ boolinq/BytesFirstToLast.) const
748 {
749 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, int>, TRet>(
750 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, direction, 0),
751 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, int>& tuple) {
752 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(d6579c74af3aef5).<0>(tuple);
753 BytesDirectioncxx . . $ boolinq/BytesDirection#& bytesDirection = stdcxx . . $ std/::getcxx . . $ std/get(58f9000eff7414f2).<1>(tuple);
754
755 /*int& index =*/ stdcxx . . $ std/::getcxx . . $ std/get(2b8af70fa318720a).<2>(tuple);
756
757 TRet value;
758 unsigned char* ptr = reinterpret_cast<unsigned char*>(&cxx . . $ `operator&`(cb51c56919ca9d76).value);
759
760 for (int i = 0; i < sizeof(TRet); i++) {
761 int byteIndex = i;
762 if (bytesDirection == BytesLastToFirstcxx . . $ boolinq/BytesLastToFirst.) {
763 byteIndex = sizeof(TRet) - 1 - byteIndex;
764 }
765
766 ptr[byteIndex] = linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
767 }
768
769 return value;
770 }
771 );
772 }
773
774 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, BitsDirectioncxx . . $ boolinq/BitsDirection#, T, int>, int> bitscxx . . $ boolinq/Linq#bits(5c9bfefc83659888).(BitsDirectioncxx . . $ boolinq/BitsDirection# bitsDir = BitsHighToLowcxx . . $ boolinq/BitsHighToLow.,
775 BytesDirectioncxx . . $ boolinq/BytesDirection# bytesDir = BytesFirstToLastcxx . . $ boolinq/BytesFirstToLast.) const
776 {
777 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, BitsDirectioncxx . . $ boolinq/BitsDirection#, T, int>, int>(
778 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, bytesDir, bitsDir, T(), sizeof(T) * CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!),
779 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, BitsDirectioncxx . . $ boolinq/BitsDirection#, T, int>& tuple) {
780 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(b5bb845d0107ee72).<0>(tuple);
781 BytesDirectioncxx . . $ boolinq/BytesDirection#& bytesDirection = stdcxx . . $ std/::getcxx . . $ std/get(b5bb845d0107ee72).<1>(tuple);
782 BitsDirectioncxx . . $ boolinq/BitsDirection#& bitsDirection = stdcxx . . $ std/::getcxx . . $ std/get(5aabc72a970aa7ce).<2>(tuple);
783 T& value = stdcxx . . $ std/::getcxx . . $ std/get(be89c998c264c45d).<3>(tuple);
784 int& index = stdcxx . . $ std/::getcxx . . $ std/get(607352554f49d4b5).<4>(tuple);
785
786 if (index == sizeof(T) * CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!) {
787 value = linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).();
788 index = 0;
789 }
790
791 unsigned char* ptr = reinterpret_cast<unsigned char*>(&cxx . . $ `operator&`(a6a1783193ab4fe4).value);
792
793 int byteIndex = index / CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!;
794 if (bytesDirection == BytesLastToFirstcxx . . $ boolinq/BytesLastToFirst.) {
795 byteIndex = sizeof(T) - 1 - byteIndex;
796 }
797
798 int bitIndex = index % CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!;
799 if (bitsDirection == BitsHighToLowcxx . . $ boolinq/BitsHighToLow.) {
800 bitIndex = CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`! - 1 - bitIndex;
801 }
802
803 index++;
804 return (ptr[byteIndex] >> bitIndex) & 1;
805 }
806 );
807 }
808
809 template<typename TRet = unsigned char>
810 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, BitsDirectioncxx . . $ boolinq/BitsDirection#, int>, TRet> unbitscxx . . $ boolinq/Linq#unbits(57f84b9d892e64ba).(BitsDirectioncxx . . $ boolinq/BitsDirection# bitsDir = BitsHighToLowcxx . . $ boolinq/BitsHighToLow.,
811 BytesDirectioncxx . . $ boolinq/BytesDirection# bytesDir = BytesFirstToLastcxx . . $ boolinq/BytesFirstToLast.) const
812 {
813 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, BitsDirectioncxx . . $ boolinq/BitsDirection#, int>, TRet>(
814 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(*this, bytesDir, bitsDir, 0),
815 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Linqcxx . . $ boolinq/Linq#<S, T>, BytesDirectioncxx . . $ boolinq/BytesDirection#, BitsDirectioncxx . . $ boolinq/BitsDirection#, int>& tuple) {
816 Linqcxx . . $ boolinq/Linq#<S, T>& linq = stdcxx . . $ std/::getcxx . . $ std/get(70afc5746c4001b1).<0>(tuple);
817 BytesDirectioncxx . . $ boolinq/BytesDirection#& bytesDirection = stdcxx . . $ std/::getcxx . . $ std/get(d6579c74af3aef5).<1>(tuple);
818 BitsDirectioncxx . . $ boolinq/BitsDirection#& bitsDirection = stdcxx . . $ std/::getcxx . . $ std/get(9a1b01079da03411).<2>(tuple);
819
820 /*int& index =*/ stdcxx . . $ std/::getcxx . . $ std/get(959d1ca383d8d70e).<3>(tuple);
821
822 TRet value = TRet();
823 unsigned char* ptr = reinterpret_cast<unsigned char*>(&cxx . . $ `operator&`(75032309f38f433f).value);
824
825 for (int i = 0; i < sizeof(TRet) * CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!; i++) {
826 int byteIndex = i / CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!;
827 if (bytesDirection == BytesLastToFirstcxx . . $ boolinq/BytesLastToFirst.) {
828 byteIndex = sizeof(TRet) - 1 - byteIndex;
829 }
830
831 int bitIndex = i % CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`!;
832 if (bitsDirection == BitsHighToLowcxx . . $ boolinq/BitsHighToLow.) {
833 bitIndex = CHAR_BITcxx . . $ `<external>/67164224788392828/limits.h:64:9`! - 1 - bitIndex;
834 }
835
836 ptr[byteIndex] &= ~(1 << bitIndex);
837 ptr[byteIndex] |= bool(linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).()) << bitIndex;
838 }
839
840 return value;
841 }
842 );
843 }
844
845 };
846
847 template<typename S, typename T>
848 stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ boolinq/`operator<<`(4c0dc587ba170bb0).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& stream, Linqcxx . . $ boolinq/Linq#<S, T> linq)
849 {
850 try {
851 while (true) {
852 stream <<cxx . . $ boolinq/`operator<<`(4c0dc587ba170bb0). linq.nextcxx . . $ boolinq/Linq#next(ec908ef952b256c2).() <<cxx . . $ boolinq/`operator<<`(4c0dc587ba170bb0). ' ';
853 }
854 }
855 catch (LinqEndExceptioncxx . . $ boolinq/LinqEndException#&) {}
856
857 return stream;
858 }
859
860 ////////////////////////////////////////////////////////////////
861 // Linq Creators
862 ////////////////////////////////////////////////////////////////
863
864 template<typename T>
865 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::paircxx . . $ std/pair#<T, T>, typename stdcxx . . $ std/::iterator_traitscxx . . $ std/iterator_traits#<T>::value_type> fromcxx . . $ boolinq/from(b7d1e764049f5e37).(const T& begin, const T& end)
866 {
867 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::paircxx . . $ std/pair#<T, T>, typename stdcxx . . $ std/::iterator_traitscxx . . $ std/iterator_traits#<T>::value_type>(
868 stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(begin, end),
869 [](stdcxx . . $ std/::paircxx . . $ std/pair#<T, T>& pair) {
870 if (pair.firstcxx . . $ std/pair#first. ==cxx . . $ `operator==`(dc37b9a333022f1a). pair.secondcxx . . $ std/pair#second.) {
871 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
872 }
873
874 return *cxx . . $ `operator*`(af256f10665d954b).(pair.firstcxx . . $ std/pair#first.++);
875 }
876 );
877 }
878
879 template<typename T>
880 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::paircxx . . $ std/pair#<T, T>, typename stdcxx . . $ std/::iterator_traitscxx . . $ std/iterator_traits#<T>::value_type> fromcxx . . $ boolinq/from(9f45fcb26f8087b3).(const T& it, int n)
881 {
882 return fromcxx . . $ boolinq/from(9f45fcb26f8087b3).(it, it +cxx . . $ operator+(4387d1935aa3f4a2). n);
883 }
884
885 template<typename T, int N>
886 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::paircxx . . $ std/pair#<const T*, const T*>, T> fromcxx . . $ boolinq/from(df7416361c4e9c64).(T (& array)[N])
887 {
888 return fromcxx . . $ boolinq/from(df7416361c4e9c64).((const T*)(&array), (const T*)(&array) +cxx . . $ operator+(b2c952fcb3c10f1b). N);
889 }
890
891 template<template<class> class TV, typename TT>
892 auto fromcxx . . $ boolinq/from(1a44d082b2747720).(const TV<TT>& container)
893 -> decltype(fromcxx . . $ boolinq/from(df7416361c4e9c64).(container.cbegin(), container.cend()))
894 {
895 return fromcxx . . $ boolinq/from(df7416361c4e9c64).(container.cbegin(), container.cend());
896 }
897
898 // std::list, std::vector, std::dequeue
899 template<template<class, class> class TV, typename TT, typename TU>
900 auto fromcxx . . $ boolinq/from(9278e34e98de3896).(const TV<TT, TU>& container)
901 -> decltype(fromcxx . . $ boolinq/from(9f45fcb26f8087b3).(container.cbegin(), container.cend()))
902 {
903 return fromcxx . . $ boolinq/from(1a44d082b2747720).(container.cbegin(), container.cend());
904 }
905
906 // std::set
907 template<template<class, class, class> class TV, typename TT, typename TS, typename TU>
908 auto fromcxx . . $ boolinq/from(8ea03c26417036c0).(const TV<TT, TS, TU>& container)
909 -> decltype(fromcxx . . $ boolinq/from(9f45fcb26f8087b3).(container.cbegin(), container.cend()))
910 {
911 return fromcxx . . $ boolinq/from(1a44d082b2747720).(container.cbegin(), container.cend());
912 }
913
914 // std::map
915 template<template<class, class, class, class> class TV, typename TK, typename TT, typename TS, typename TU>
916 auto fromcxx . . $ boolinq/from(66ff797f05958653).(const TV<TK, TT, TS, TU>& container)
917 -> decltype(fromcxx . . $ boolinq/from(9f45fcb26f8087b3).(container.cbegin(), container.cend()))
918 {
919 return fromcxx . . $ boolinq/from(66ff797f05958653).(container.cbegin(), container.cend());
920 }
921
922 // std::array
923 template<template<class, size_t> class TV, typename TT, size_t TL>
924 auto fromcxx . . $ boolinq/from(f28c96fa637d1d36).(const TV<TT, TL>& container)
925 -> decltype(fromcxx . . $ boolinq/from(66ff797f05958653).(container.cbegin(), container.cend()))
926 {
927 return fromcxx . . $ boolinq/from(9278e34e98de3896).(container.cbegin(), container.cend());
928 }
929
930 template<typename T>
931 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::paircxx . . $ std/pair#<T, int>, T> repeatcxx . . $ boolinq/repeat(bff34c14f66a39c6).(const T& value, int count) {
932 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::paircxx . . $ std/pair#<T, int>, T>(
933 stdcxx . . $ std/::make_paircxx . . $ std/make_pair(1d30b6e115203116).(value, count),
934 [](stdcxx . . $ std/::paircxx . . $ std/pair#<T, int>& pair) {
935 if (pair.secondcxx . . $ std/pair#second. > 0) {
936 pair.secondcxx . . $ std/pair#second.--;
937 return pair.firstcxx . . $ std/pair#first.;
938 }
939
940 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
941 }
942 );
943 }
944
945 template<typename T>
946 Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<T, T, T>, T> rangecxx . . $ boolinq/range(e638d8149add96b4).(const T& start, const T& end, const T& step) {
947 return Linqcxx . . $ boolinq/Linq#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<T, T, T>, T>(
948 stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(start, end, step),
949 [](stdcxx . . $ std/::tuplecxx . . $ std/tuple#<T, T, T>& tuple) {
950 T& start = stdcxx . . $ std/::getcxx . . $ std/get(b5bb845d0107ee72).<0>(tuple);
951 T& end = stdcxx . . $ std/::getcxx . . $ std/get(3745fbf9a4df67d6).<1>(tuple);
952 T& step = stdcxx . . $ std/::getcxx . . $ std/get(70afc5746c4001b1).<2>(tuple);
953
954 T value = start;
955 if (value < end) {
956 start +=cxx . . $ `operator+=`(79c69f12ebd2f310). step;
957 return value;
958 }
959
960 throw LinqEndExceptioncxx . . $ boolinq/LinqEndException#();
961 }
962 );
963 }
964
965 }