Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-zip.cc
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
33
38# include <gtest/gtest.h>
39
40# include <ah-zip.H>
41# include <ahFunctional.H>
42# include <ah-string-utils.H>
43# include <tpl_dynSetTree.H>
44# include <tpl_dynArray.H>
45# include <tpl_array.H>
46# include <tpl_dynSetHash.H>
47
48using namespace std;
49using namespace Aleph;
50
58
59struct CompleteGroup : public testing::Test
60{
61 static constexpr size_t N = 5;
62 DynList<int> l1 = range<int>(0, N - 1);
63 DynSetTree<int> l2 = range<int>(0, N - 1);
65 range<int>(0, N - 1).maps<string>([] (auto i) { return to_string(i); });
66 DynSkipList<int> l4 = range<int>(0, N - 1);
67};
68
69struct InCompleteGroup : public testing::Test
70{
71 DynList<int> l1 = { 0, 1, 2, 3, 4 };
72 DynSetTree<int> l2 = { 0, 1, 2, 3 };
73 DynArray<string> l3 = { "0", "1", "2", "3", "4" };
74 DynSkipList<int> l4 = { 0, 1, 2 }; // Different length
75};
76
78{
79 {
80 auto it = zip_it(l1, l2 , l3);
81 ASSERT_FALSE(it.has_curr());
82 ASSERT_THROW(it.get_curr(), std::overflow_error);
83 ASSERT_THROW(it.next(), std::overflow_error);
84 }
85 {
86 auto it = zip_it(l1, l2, l3, l4);
87 ASSERT_FALSE(it.has_curr());
88 ASSERT_THROW(it.get_curr(), std::overflow_error);
89 ASSERT_THROW(it.next(), std::overflow_error);
90 }
91 {
92 auto it = zip_it(l1);
93 ASSERT_FALSE(it.has_curr());
94 ASSERT_THROW(it.get_curr(), std::overflow_error);
95 ASSERT_THROW(it.next(), std::overflow_error);
96 }
97
98 ASSERT_NO_THROW(zip_it_pos(0, l1, l2, l3));
99 ASSERT_THROW(zip_it_pos(1, l1, l2, l3), std::overflow_error);
100
101 {
102 auto it = enum_zip_it(l1, l2 , l3);
103 ASSERT_FALSE(it.has_curr());
104 ASSERT_THROW(it.get_curr(), std::overflow_error);
105 ASSERT_THROW(it.next(), std::overflow_error);
106 }
107 {
108 auto it = enum_zip_it(l1);
109 ASSERT_FALSE(it.has_curr());
110 ASSERT_THROW(it.get_curr(), std::overflow_error);
111 ASSERT_THROW(it.next(), std::overflow_error);
112 }
113
114 ASSERT_NO_THROW(enum_zip_it_pos(0, l1, l2, l3));
115 ASSERT_THROW(enum_zip_it_pos(1, l1, l2, l3), std::overflow_error);
116}
117
119{
120 size_t i = 0;
121 for (auto it = zip_it(l1, l2, l3); it.has_curr(); it.next_ne(), ++i)
122 {
123 auto t = it.get_curr_ne();
124 EXPECT_EQ(get<0>(t), i);
125 EXPECT_EQ(get<1>(t), i);
126 EXPECT_EQ(get<2>(t), to_string(i));
127 }
128
129 i = 1;
130 for (auto it = zip_it_pos(1, l1, l2, l3); it.has_curr(); it.next_ne(), ++i)
131 {
132 auto t = it.get_curr_ne();
133 EXPECT_EQ(get<0>(t), i);
134 EXPECT_EQ(get<1>(t), i);
135 EXPECT_EQ(get<2>(t), to_string(i));
136 }
137
138 for (auto it = enum_zip_it(l1, l2, l3); it.has_curr(); it.next_ne())
139 {
140 auto t = it.get_curr_ne();
141 auto & i = get<3>(t);
142 EXPECT_EQ(get<0>(t), i);
143 EXPECT_EQ(get<1>(t), i);
144 EXPECT_EQ(get<2>(t), to_string(i));
145 }
146}
147
148TEST_F(InCompleteGroup, ml_operations)
149{
150 EXPECT_FALSE(equal_length(l1, l2, l3));
151 EXPECT_TRUE(zip_traverse([] (auto t) { return get<0>(t) == get<1>(t)
152 and to_string(get<0>(t)) == get<2>(t); }, l1, l2, l3));
153 EXPECT_FALSE(zip_traverse_eq([] (auto t) { return get<0>(t) == get<1>(t)
154 and to_string(get<0>(t)) == get<2>(t); }, l1, l2, l3));
155 EXPECT_NO_THROW(zip_for_each([] (auto) { return; }, l1, l2, l3));
156 EXPECT_THROW(zip_for_each_eq([] (auto) { return; }, l1, l2, l3),
157 length_error);
158
159 size_t i = 0;
160 zip_for_each([&i] (auto t)
161 {
162 EXPECT_EQ(get<0>(t), i++);
163 EXPECT_EQ(get<0>(t), get<1>(t));
164 EXPECT_EQ(to_string(get<0>(t)), get<2>(t));
165 }, l1, l2, l3);
166
167 i = 0;
168 EXPECT_THROW(zip_for_each_eq([&i] (auto t)
169 {
170 EXPECT_EQ(get<0>(t), i++);
171 EXPECT_EQ(get<0>(t), get<1>(t));
172 EXPECT_EQ(to_string(get<0>(t)), get<2>(t));
173 }, l1, l2, l3), length_error);
174
175 EXPECT_FALSE(zip_all([] (auto t) { return get<0>(t) == get<1>(t)
176 and to_string(get<0>(t)) == get<2>(t); }, l1, l2, l3));
177 EXPECT_TRUE(zip_exists([] (auto t) { return get<0>(t) == get<1>(t) and
178 get<2>(t) == "3"; }, l1, l2, l3));
179
180 auto lmap = zip_maps<string>([] (auto t)
181 {
182 return to_string(get<0>(t)) +
183 to_string(get<1>(t)) + get<2>(t);
184 }, l1, l2, l3);
185 EXPECT_EQ(lmap, build_dynlist<string>("000", "111", "222", "333"));
186
187 lmap = zip_maps_if<string>([] (auto t) { return get<0>(t) != 1; },
188 [] (auto t)
189 {
190 return to_string(get<0>(t)) +
191 to_string(get<1>(t)) + get<2>(t);
192 }, l1, l2, l3);
193 EXPECT_EQ(lmap, build_dynlist<string>("000", "222", "333"));
194
195 EXPECT_THROW(t_zip_eq(l1, l2, l3), length_error);
196}
197
198TEST_F(CompleteGroup, ml_operations)
199{
200 EXPECT_TRUE(equal_length(l1, l2, l3));
201 EXPECT_TRUE(zip_traverse([] (auto t) { return get<0>(t) == get<1>(t)
202 and to_string(get<0>(t)) == get<2>(t); }, l1, l2, l3));
203 EXPECT_NO_THROW((void)zip_traverse_eq([] (auto t) { return get<0>(t) == get<1>(t)
204 and to_string(get<0>(t)) == get<2>(t); }, l1, l2, l3));
205 zip_for_each([] (auto t)
206 {
207 EXPECT_EQ(get<0>(t), get<1>(t));
208 EXPECT_EQ(to_string(get<0>(t)), get<2>(t));
209 }, l1, l2, l3);
210 zip_for_each_eq([] (auto t)
211 {
212 EXPECT_EQ(get<0>(t), get<1>(t));
213 EXPECT_EQ(to_string(get<0>(t)), get<2>(t));
214 }, l1, l2, l3);
215 EXPECT_TRUE(zip_all([] (auto t) { return get<0>(t) == get<1>(t)
216 and to_string(get<0>(t)) == get<2>(t); }, l1, l2, l3));
217 EXPECT_TRUE(zip_exists([] (auto t) { return get<0>(t) == get<1>(t) and
218 get<2>(t) == "3"; }, l1, l2, l3));
219 EXPECT_FALSE(zip_exists([] (auto t) { return get<0>(t) == get<1>(t) and
220 get<2>(t) == "7"; }, l1, l2, l3));
221
222 auto lmap = zip_maps<string>([] (auto t)
223 {
224 return to_string(get<0>(t)) +
225 to_string(get<1>(t)) + get<2>(t);
226 }, l1, l2, l3);
227 EXPECT_EQ(lmap, build_dynlist<string>("000", "111", "222", "333", "444"));
228
229 lmap = zip_maps_if<string>([] (auto t) { return get<0>(t) != 1; },
230 [] (auto t)
231 {
232 return to_string(get<0>(t)) +
233 to_string(get<1>(t)) + get<2>(t);
234 }, l1, l2, l3);
235 EXPECT_EQ(lmap, build_dynlist<string>("000", "222", "333", "444"));
236
237 auto sum = zip_foldl(0, [] (auto a, auto t)
238 { return a + get<0>(t) + get<1>(t); }, l1, l2, l3);
239 EXPECT_EQ(sum, N*(N- 1));
240
241 auto lfilt = zip_filter([] (auto t)
242 { return get<1>(t) != 2; }, l1, l2, l3);
244 { make_tuple(0, 0, "0"), make_tuple(1, 1, "1"),
245 make_tuple(3, 3, "3"), make_tuple(4, 4, "4") };
246 EXPECT_EQ(lfilt, expl);
247
248 EXPECT_TRUE(zip_cmp([] (auto & i1, auto & i2) { return i1 == i2; },
249 l1, l2, l1, l2));
250
251 auto l1_mutated = l1; l1_mutated.nth(3) = 4;
252 EXPECT_FALSE(zip_cmp([] (auto & i1, auto & i2) { return i1 == i2; },
253 l1, l2, l1_mutated, l2));
254
255 auto lzip = t_zip(l1, l2, l3);
256 for (auto it = zip_it(lzip, l1, l2, l3); it.has_curr(); it.next_ne())
257 {
258 auto t = it.get_curr_ne();
259 auto & tz = get<0>(t);
260 EXPECT_EQ(get<0>(tz), get<1>(t));
261 }
262
263 auto uzip = t_unzip(lzip);
264 EXPECT_EQ(get<0>(uzip), l1);
265 EXPECT_EQ(get<1>(uzip), l2.keys());
266 EXPECT_TRUE(eq(get<2>(uzip), l3));
267
268 auto idx = zip_find_index([] (auto t)
269 {
270 return get<0>(t) == get<1>(t) and
271 to_string(get<1>(t)) == get<2>(t) and
272 get<0>(t) == N - 1;
273 }, l1, l2, l3);
274 EXPECT_EQ(idx, N - 1);
275
276 idx = zip_find_index([] (auto t)
277 {
278 return get<0>(t) == N;
279 }, l1, l2, l3);
280 EXPECT_EQ(idx, N - 0 /* for avoiding linker error with constant */);
281
282 auto part = zip_partition([] (auto t) { return get<0>(t) < 2; }, l1, l2, l3);
283
284 EXPECT_TRUE(eq(get<0>(part).maps<string>([] (auto & t)
285 {
286 return to_string(get<0>(t)) + to_string(get<1>(t)) + get<2>(t);
287 }), build_dynlist<string>("000", "111")));
288 EXPECT_EQ(get<1>(part), 2);
289 EXPECT_TRUE(eq(get<2>(part).maps<string>([] (auto & t)
290 {
291 return to_string(get<0>(t)) + to_string(get<1>(t)) + get<2>(t);
292 }), build_dynlist<string>("222", "333", "444")));
293 EXPECT_EQ(get<3>(part), N - 2);
294
295 auto l = zip_lists(l1, l2, l1, l2);
296 for (auto it = zip_it(l, l1, l2); it.has_curr(); it.next_ne())
297 {
298 auto c = it.get_curr_ne();
299 EXPECT_EQ(get<0>(c), build_dynlist<int>(get<1>(c), get<2>(c),
300 get<1>(c), get<2>(c)));
301 }
302}
303
304// ==================== NEW TESTS ====================
305
306// Test zip_lists_eq with equal length containers
307TEST_F(CompleteGroup, zip_lists_eq_success)
308{
309 auto result = zip_lists_eq(l1, l2, l1);
310
311 EXPECT_EQ(result.size(), N);
312
313 size_t i = 0;
314 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
315 {
316 auto & inner_list = it.get_curr();
317 EXPECT_EQ(inner_list.size(), 3);
318 auto inner_it = inner_list.get_it();
319 EXPECT_EQ(inner_it.get_curr(), i); // from l1
320 inner_it.next();
321 EXPECT_EQ(inner_it.get_curr(), i); // from l2
322 inner_it.next();
323 EXPECT_EQ(inner_it.get_curr(), i); // from l1 again
324 }
325}
326
327// Test zip_lists_eq with unequal length containers - should throw
328TEST_F(InCompleteGroup, zip_lists_eq_throws)
329{
330 DynList<int> l_short = { 0, 1, 2 };
331 DynList<int> l_long = { 0, 1, 2, 3, 4 };
332
333 EXPECT_THROW(zip_lists_eq(l_short, l_long), length_error);
334}
335
336// Test t_enum_zip
337TEST_F(CompleteGroup, t_enum_zip_basic)
338{
339 auto result = t_enum_zip(l1, l2);
340
341 EXPECT_EQ(result.size(), N);
342
343 for (auto it = result.get_it(); it.has_curr(); it.next_ne())
344 {
345 auto t = it.get_curr();
346 auto idx = get<2>(t); // Index is last element
347 EXPECT_EQ(get<0>(t), idx); // l1 value should match index
348 EXPECT_EQ(get<1>(t), idx); // l2 value should match index
349 }
350}
351
352// Test t_enum_zip_eq with equal containers
353TEST_F(CompleteGroup, t_enum_zip_eq_success)
354{
355 auto result = t_enum_zip_eq(l1, l2);
356
357 EXPECT_EQ(result.size(), N);
358
359 size_t expected_idx = 0;
360 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++expected_idx)
361 {
362 auto t = it.get_curr();
363 EXPECT_EQ(get<2>(t), expected_idx);
364 }
365}
366
367// Test t_enum_zip_eq with unequal containers - should throw
368TEST_F(InCompleteGroup, t_enum_zip_eq_throws)
369{
370 EXPECT_THROW(t_enum_zip_eq(l1, l2), length_error);
371}
372
373// Test std_zip with STL vectors
374TEST(StdZip, basic_vectors)
375{
376 vector<int> v1 = { 1, 2, 3, 4, 5 };
377 vector<string> v2 = { "a", "b", "c", "d", "e" };
378
379 auto result = std_zip(v1, v2);
380
381 EXPECT_EQ(result.size(), 5);
382
383 for (size_t i = 0; i < result.size(); ++i)
384 {
385 EXPECT_EQ(result[i].first, static_cast<int>(i + 1));
386 EXPECT_EQ(result[i].second, string(1, 'a' + i));
387 }
388}
389
390// Test std_zip with unequal length - should stop at shorter
391TEST(StdZip, unequal_lengths)
392{
393 vector<int> v1 = { 1, 2, 3 };
394 vector<int> v2 = { 10, 20, 30, 40, 50 };
395
396 auto result = std_zip(v1, v2);
397
398 EXPECT_EQ(result.size(), 3); // Stops at shorter container
399 EXPECT_EQ(result[0].first, 1);
400 EXPECT_EQ(result[0].second, 10);
401 EXPECT_EQ(result[2].first, 3);
402 EXPECT_EQ(result[2].second, 30);
403}
404
405// Test tzip_std with 2 STL containers (variadic version)
406TEST(TzipStd, two_containers)
407{
408 vector<int> v1 = { 1, 2, 3 };
409 vector<string> v2 = { "a", "b", "c" };
410
411 auto result = tzip_std(v1, v2);
412
413 EXPECT_EQ(result.size(), 3);
414 EXPECT_EQ(get<0>(result[0]), 1);
415 EXPECT_EQ(get<1>(result[0]), "a");
416 EXPECT_EQ(get<0>(result[2]), 3);
417 EXPECT_EQ(get<1>(result[2]), "c");
418}
419
420// Test tzip_std with 3 STL containers
421TEST(TzipStd, three_containers)
422{
423 vector<int> v1 = { 1, 2, 3 };
424 vector<double> v2 = { 1.1, 2.2, 3.3 };
425 vector<char> v3 = { 'a', 'b', 'c' };
426
427 auto result = tzip_std(v1, v2, v3);
428
429 EXPECT_EQ(result.size(), 3);
430 EXPECT_EQ(get<0>(result[0]), 1);
431 EXPECT_DOUBLE_EQ(get<1>(result[0]), 1.1);
432 EXPECT_EQ(get<2>(result[0]), 'a');
433}
434
435// Test tzip_std with 4 STL containers
436TEST(TzipStd, four_containers)
437{
438 vector<int> v1 = { 1, 2, 3 };
439 vector<double> v2 = { 1.1, 2.2, 3.3 };
440 vector<char> v3 = { 'a', 'b', 'c' };
441 vector<string> v4 = { "x", "y", "z" };
442
443 auto result = tzip_std(v1, v2, v3, v4);
444
445 EXPECT_EQ(result.size(), 3);
446
447 EXPECT_EQ(get<0>(result[0]), 1);
448 EXPECT_DOUBLE_EQ(get<1>(result[0]), 1.1);
449 EXPECT_EQ(get<2>(result[0]), 'a');
450 EXPECT_EQ(get<3>(result[0]), "x");
451
452 EXPECT_EQ(get<0>(result[2]), 3);
453 EXPECT_DOUBLE_EQ(get<1>(result[2]), 3.3);
454 EXPECT_EQ(get<2>(result[2]), 'c');
455 EXPECT_EQ(get<3>(result[2]), "z");
456}
457
458// Test tzip_std with 5 STL containers
459TEST(TzipStd, five_containers)
460{
461 vector<int> v1 = { 1, 2 };
462 vector<double> v2 = { 1.1, 2.2 };
463 vector<char> v3 = { 'a', 'b' };
464 vector<string> v4 = { "x", "y" };
465 vector<long> v5 = { 100L, 200L };
466
467 auto result = tzip_std(v1, v2, v3, v4, v5);
468
469 EXPECT_EQ(result.size(), 2);
470 EXPECT_EQ(get<0>(result[0]), 1);
471 EXPECT_DOUBLE_EQ(get<1>(result[0]), 1.1);
472 EXPECT_EQ(get<2>(result[0]), 'a');
473 EXPECT_EQ(get<3>(result[0]), "x");
474 EXPECT_EQ(get<4>(result[0]), 100L);
475}
476
477TEST(StdZipN, alias_matches_tzip_std)
478{
479 vector<int> v1 = { 1, 2, 3 };
480 vector<double> v2 = { 1.1, 2.2, 3.3 };
481 vector<string> v3 = { "a", "b", "c" };
482
483 auto a = tzip_std(v1, v2, v3);
484 auto b = std_zip_n(v1, v2, v3);
485 EXPECT_EQ(a, b);
486}
487
488TEST(StdZipN, stops_at_shortest)
489{
490 vector<int> v1 = { 1, 2 };
491 vector<int> v2 = { 10, 20, 30 };
492 vector<int> v3 = { 100, 200, 300, 400 };
493
494 auto result = std_zip_n(v1, v2, v3);
495 EXPECT_EQ(result.size(), 2);
496 EXPECT_EQ(get<0>(result[0]), 1);
497 EXPECT_EQ(get<1>(result[0]), 10);
498 EXPECT_EQ(get<2>(result[0]), 100);
499}
500
501// Test tzip_std with unequal lengths
502TEST(TzipStd, unequal_lengths)
503{
504 vector<int> v1 = { 1, 2 };
505 vector<int> v2 = { 10, 20, 30 };
506 vector<int> v3 = { 100, 200, 300, 400 };
507 vector<int> v4 = { 1000, 2000, 3000, 4000, 5000 };
508
509 auto result = tzip_std(v1, v2, v3, v4);
510
511 EXPECT_EQ(result.size(), 2); // Stops at shortest
512}
513
514// Test single container zip
515TEST(SingleContainerZip, basic)
516{
517 DynList<int> l = { 1, 2, 3, 4, 5 };
518
519 auto it = zip_it(l);
520 size_t count = 0;
521 for (; it.has_curr(); it.next_ne(), ++count)
522 {
523 auto t = it.get_curr_ne();
524 EXPECT_EQ(get<0>(t), static_cast<int>(count + 1));
525 }
526 EXPECT_EQ(count, 5);
527}
528
529// Test equal_length with single container
530TEST(SingleContainerZip, equal_length_single)
531{
532 DynList<int> l = { 1, 2, 3 };
533 EXPECT_TRUE(equal_length(l));
534}
535
536// Test get_curr_list with homogeneous containers - verify correct order
537TEST_F(CompleteGroup, get_curr_list_homogeneous)
538{
539 DynList<int> a = { 1, 2, 3 };
540 DynList<int> b = { 10, 20, 30 };
541 DynList<int> c = { 100, 200, 300 };
542
543 auto it = zip_it(a, b, c);
544
545 ASSERT_TRUE(it.has_curr());
546 auto curr_list = it.get_curr_list();
547
548 // Should have 3 elements in order: 1 (from a), 10 (from b), 100 (from c)
549 EXPECT_EQ(curr_list.size(), 3);
550 auto list_it = curr_list.get_it();
551 EXPECT_EQ(list_it.get_curr(), 1); // First element from first container
552 list_it.next();
553 EXPECT_EQ(list_it.get_curr(), 10); // Second element from second container
554 list_it.next();
555 EXPECT_EQ(list_it.get_curr(), 100); // Third element from third container
556
557 // Advance and check second position
558 it.next();
559 curr_list = it.get_curr_list();
560 list_it = curr_list.get_it();
561 EXPECT_EQ(list_it.get_curr(), 2);
562 list_it.next();
563 EXPECT_EQ(list_it.get_curr(), 20);
564 list_it.next();
565 EXPECT_EQ(list_it.get_curr(), 200);
566}
567
568// Test zip_cmp with different predicates
569TEST_F(CompleteGroup, zip_cmp_less_than)
570{
571 DynList<int> ascending1 = { 1, 2, 3, 4, 5 };
572 DynList<int> ascending2 = { 2, 3, 4, 5, 6 };
573
574 // All elements in ascending1 should be less than corresponding elements in ascending2
575 EXPECT_TRUE(zip_cmp([] (auto & a, auto & b) { return a < b; },
576 ascending1, ascending2));
577}
578
579// Test with empty containers
580TEST(EmptyContainerTests, all_empty)
581{
582 DynList<int> empty1, empty2, empty3;
583
584 EXPECT_TRUE(equal_length(empty1, empty2, empty3));
585 EXPECT_TRUE(zip_traverse([] (auto) { return true; }, empty1, empty2));
586 EXPECT_TRUE(zip_all([] (auto) { return true; }, empty1, empty2));
587 EXPECT_FALSE(zip_exists([] (auto) { return true; }, empty1, empty2));
588
589 auto mapped = zip_maps<int>([] (auto t) { return get<0>(t); }, empty1, empty2);
590 EXPECT_TRUE(mapped.is_empty());
591
592 auto filtered = zip_filter([] (auto) { return true; }, empty1, empty2);
593 EXPECT_TRUE(filtered.is_empty());
594
595 auto zipped = t_zip(empty1, empty2);
596 EXPECT_TRUE(zipped.is_empty());
597}
598
599// Test noexcept guarantees for _ne methods
600TEST_F(CompleteGroup, noexcept_methods)
601{
602 auto it = zip_it(l1, l4);
603
604 // These should be noexcept
605 EXPECT_TRUE(noexcept(it.get_curr_ne()));
606 EXPECT_TRUE(noexcept(it.next_ne()));
607
608 auto enum_it = enum_zip_it(l1, l4);
609 EXPECT_TRUE(noexcept(enum_it.get_curr_ne()));
610 EXPECT_TRUE(noexcept(enum_it.next_ne()));
611
612 // The iterator of a binary tree may move its pending nodes to the heap
613 // while it advances, so next_ne() is not noexcept once a tree is zipped,
614 // whatever its place among the containers.
615 EXPECT_FALSE(noexcept(std::declval<DynSetTree<int>::Iterator &>().next_ne()));
616
617 auto tree_first = zip_it(l2, l1);
618 auto tree_last = zip_it(l1, l2);
619 EXPECT_TRUE(noexcept(tree_first.get_curr_ne()));
620 EXPECT_FALSE(noexcept(tree_first.next_ne()));
621 EXPECT_FALSE(noexcept(tree_last.next_ne()));
622
623 auto enum_tree_first = enum_zip_it(l2, l1);
624 auto enum_tree_last = enum_zip_it(l1, l2);
625 EXPECT_TRUE(noexcept(enum_tree_first.get_curr_ne()));
626 EXPECT_FALSE(noexcept(enum_tree_first.next_ne()));
627 EXPECT_FALSE(noexcept(enum_tree_last.next_ne()));
628
629 auto pair_it = get_pair_it(l1, l4);
630 auto pair_tree_first = get_pair_it(l2, l1);
631 auto pair_tree_last = get_pair_it(l1, l2);
632 EXPECT_TRUE(noexcept(pair_it.next_ne()));
633 EXPECT_FALSE(noexcept(pair_tree_first.next_ne()));
634 EXPECT_FALSE(noexcept(pair_tree_last.next_ne()));
635}
636
637// The inorder iterator of a tree keeps inline up to 128 pending nodes. In
638// this tree it needs many more, and not when it is built but in its first
639// next_ne(): the minimum is the root, the maximum is its right child, and
640// all the other keys go down the left spine of the maximum.
641TEST(DeepTree, zip_iterators_advance_past_the_inline_capacity)
642{
643 constexpr int n = 1000;
645 tree.insert(0);
646 for (int i = n; i > 0; --i)
647 tree.insert(i);
648 ASSERT_EQ(tree.height(), static_cast<size_t>(n) + 1);
649
650 const DynList<int> list = range<int>(0, n);
651
652 int expected = 0;
653 for (auto it = zip_it(tree, list); it.has_curr(); it.next_ne(), ++expected)
654 ASSERT_EQ(it.get_curr_ne(), make_tuple(expected, expected));
655 EXPECT_EQ(expected, n + 1);
656
657 expected = 0;
658 for (auto it = zip_it(list, tree); it.has_curr(); it.next_ne(), ++expected)
659 ASSERT_EQ(it.get_curr_ne(), make_tuple(expected, expected));
660 EXPECT_EQ(expected, n + 1);
661
662 size_t index = 0;
663 for (auto it = enum_zip_it(tree, list); it.has_curr(); it.next_ne(), ++index)
664 ASSERT_EQ(it.get_curr_ne(),
665 make_tuple(static_cast<int>(index), static_cast<int>(index), index));
666 EXPECT_EQ(index, static_cast<size_t>(n) + 1);
667
668 index = 0;
669 for (auto it = enum_zip_it(list, tree); it.has_curr(); it.next_ne(), ++index)
670 ASSERT_EQ(it.get_curr_ne(),
671 make_tuple(static_cast<int>(index), static_cast<int>(index), index));
672 EXPECT_EQ(index, static_cast<size_t>(n) + 1);
673
674 expected = 0;
675 for (auto it = get_pair_it(tree, list); it.has_curr(); it.next_ne(), ++expected)
676 ASSERT_EQ(it.get_curr_ne(), make_pair(expected, expected));
677 EXPECT_EQ(expected, n + 1);
678}
679
680// Stress test with larger containers
681TEST(StressTest, large_containers)
682{
683 const size_t SIZE = 1000;
684 DynList<int> l1 = range<int>(0, SIZE - 1);
685 DynList<int> l2 = range<int>(0, SIZE - 1);
686
687 EXPECT_TRUE(equal_length(l1, l2));
688
689 auto sum = zip_foldl(0, [] (auto acc, auto t)
690 { return acc + get<0>(t) + get<1>(t); }, l1, l2);
691
692 // Sum of 0..999 is 499500, and we have two lists
693 EXPECT_EQ(sum, 2 * (SIZE * (SIZE - 1) / 2));
694
695 auto zipped = t_zip(l1, l2);
696 EXPECT_EQ(zipped.size(), SIZE);
697}
698
699// Test zip_find_index edge cases
700TEST_F(CompleteGroup, zip_find_index_not_found)
701{
702 // Should return N (size of containers) if not found
703 auto idx = zip_find_index([] (auto t) { return get<0>(t) == 999; }, l1, l2);
704 EXPECT_EQ(idx, N);
705}
706
707TEST_F(CompleteGroup, zip_find_index_first_element)
708{
709 auto idx = zip_find_index([] (auto t) { return get<0>(t) == 0; }, l1, l2);
710 EXPECT_EQ(idx, 0);
711}
712
713// Test completed() behavior
714TEST_F(CompleteGroup, completed_behavior)
715{
716 auto it = zip_it(l1, l2, l3);
717
718 // Iterate to the end
719 while (it.has_curr())
720 it.next_ne();
721
722 // All containers same length, so completed() should be true
723 EXPECT_TRUE(it.completed());
724}
725
726TEST_F(InCompleteGroup, completed_behavior_incomplete)
727{
728 auto it = zip_it(l1, l2, l3);
729
730 // Iterate to the end (stops at shortest)
731 while (it.has_curr())
732 it.next_ne();
733
734 // l2 is shorter, so not all are completed
735 EXPECT_FALSE(it.completed());
736}
737
738// Test zip with 5 different container types and heterogeneous element types
739TEST(HeterogeneousContainers, five_different_containers)
740{
741 // 5 distinct container types with different element types
742 DynList<int> c1 = { 1, 2, 3 };
743 DynSetTree<double> c2 = { 1.1, 2.2, 3.3 };
744 DynArray<string> c3 = { "a", "b", "c" };
745 Array<char> c4 = { 'x', 'y', 'z' }; // Use initializer list
746 DynList<long> c5 = { 100L, 200L, 300L };
747
748 // Iterate over all 5 containers simultaneously
749 size_t count = 0;
750 for (auto it = zip_it(c1, c2, c3, c4, c5); it.has_curr(); it.next_ne(), ++count)
751 {
752 auto t = it.get_curr_ne();
753 // t is tuple<int, double, string, char, long>
754 EXPECT_EQ(get<0>(t), static_cast<int>(count + 1));
755 EXPECT_DOUBLE_EQ(get<1>(t), (count + 1) * 1.1);
756 EXPECT_EQ(get<2>(t), string(1, 'a' + count));
757 EXPECT_EQ(get<3>(t), 'x' + count);
758 EXPECT_EQ(get<4>(t), (count + 1) * 100L);
759 }
760 EXPECT_EQ(count, 3);
761
762 // Verify equal_length works with 5 containers
763 EXPECT_TRUE(equal_length(c1, c2, c3, c4, c5));
764
765 // Test zip_for_each with 5 containers
766 count = 0;
767 zip_for_each([&count](auto t) {
768 ++count;
769 // Verify tuple has correct types
770 static_assert(std::is_same_v<std::decay_t<decltype(get<0>(t))>, int>);
771 static_assert(std::is_same_v<std::decay_t<decltype(get<1>(t))>, double>);
772 static_assert(std::is_same_v<std::decay_t<decltype(get<2>(t))>, string>);
773 static_assert(std::is_same_v<std::decay_t<decltype(get<3>(t))>, char>);
774 static_assert(std::is_same_v<std::decay_t<decltype(get<4>(t))>, long>);
775 }, c1, c2, c3, c4, c5);
776 EXPECT_EQ(count, 3);
777}
778
779// Test with Array container specifically
780TEST(ArrayContainer, basic_zip_with_array)
781{
782 Array<int> arr1 = { 10, 20, 30, 40 }; // Use initializer list
783 Array<string> arr2 = { "ten", "twenty", "thirty", "forty" };
784 DynList<double> list = { 1.0, 2.0, 3.0, 4.0 };
785
786 size_t count = 0;
787 for (auto it = zip_it(arr1, arr2, list); it.has_curr(); it.next_ne(), ++count)
788 {
789 auto t = it.get_curr_ne();
790 EXPECT_EQ(get<0>(t), (count + 1) * 10);
791 EXPECT_EQ(get<2>(t), count + 1.0);
792 }
793 EXPECT_EQ(count, 4);
794
795 EXPECT_TRUE(equal_length(arr1, arr2, list));
796}
797
798// Test with hash table containers
799TEST(HashContainers, zip_with_dynset_hash)
800{
801 // DynSetHash - hash set with linear probing
802 DynSetLhash<int> hash_set = { 10, 20, 30, 40, 50 };
803 DynList<int> list = { 1, 2, 3, 4, 5 };
804
805 // Both have 5 elements
806 EXPECT_EQ(hash_set.size(), 5);
807 EXPECT_EQ(list.size(), 5);
808 EXPECT_TRUE(equal_length(hash_set, list));
809
810 // Iterate and count (hash order is not deterministic, so just check count)
811 size_t count = 0;
812 for (auto it = zip_it(hash_set, list); it.has_curr(); it.next_ne(), ++count)
813 {
814 auto t = it.get_curr_ne();
815 // get<0>(t) is from hash_set (some int in {10,20,30,40,50})
816 // get<1>(t) is from list (sequential 1,2,3,4,5)
817 EXPECT_TRUE(hash_set.contains(get<0>(t)));
818 }
819 EXPECT_EQ(count, 5);
820
821 // Test with multiple hash containers
822 DynSetLhash<string> hash_strings = { "a", "b", "c" };
823 DynSetLhash<double> hash_doubles = { 1.1, 2.2, 3.3 };
824 DynList<int> indices = { 0, 1, 2 };
825
826 EXPECT_TRUE(equal_length(hash_strings, hash_doubles, indices));
827
828 count = 0;
829 zip_for_each([&count](auto t) {
830 ++count;
831 // Verify types are correct
832 static_assert(std::is_same_v<std::decay_t<decltype(get<0>(t))>, string>);
833 static_assert(std::is_same_v<std::decay_t<decltype(get<1>(t))>, double>);
834 static_assert(std::is_same_v<std::decay_t<decltype(get<2>(t))>, int>);
835 }, hash_strings, hash_doubles, indices);
836 EXPECT_EQ(count, 3);
837}
838
839// Test mixing hash containers with tree and list containers
840TEST(HashContainers, mixed_hash_tree_list)
841{
842 DynSetLhash<int> hash = { 1, 2, 3, 4 };
843 DynSetTree<int> tree = { 10, 20, 30, 40 };
844 DynList<string> list = { "a", "b", "c", "d" };
845 Array<double> arr = { 1.1, 2.2, 3.3, 4.4 };
846
847 EXPECT_TRUE(equal_length(hash, tree, list, arr));
848
849 size_t count = 0;
850 for (auto it = zip_it(hash, tree, list, arr); it.has_curr(); it.next_ne(), ++count)
851 {
852 auto t = it.get_curr_ne();
853 // Just verify we can access all elements
854 EXPECT_TRUE(hash.contains(get<0>(t)));
855 EXPECT_TRUE(tree.contains(get<1>(t)));
856 }
857 EXPECT_EQ(count, 4);
858}
859
860// ============================================================================
861// Tests for new features (issues 16, 17, 19, 20)
862// ============================================================================
863
864// ---------- Issue 16: zip_transform ----------
865
866TEST_F(CompleteGroup, zip_transform_basic)
867{
868 // Transform tuples into concatenated strings
869 auto result = zip_transform([](auto t) {
870 return to_string(get<0>(t)) + "-" + to_string(get<1>(t)) + "-" + get<2>(t);
871 }, l1, l2, l3);
872
873 EXPECT_EQ(result.size(), N);
874 EXPECT_EQ(result[0], "0-0-0");
875 EXPECT_EQ(result[1], "1-1-1");
876 EXPECT_EQ(result[N-1], to_string(N-1) + "-" + to_string(N-1) + "-" + to_string(N-1));
877}
878
879TEST_F(CompleteGroup, zip_transform_numeric)
880{
881 // Transform to sum of elements
882 auto result = zip_transform([](auto t) {
883 return get<0>(t) + get<1>(t);
884 }, l1, l2);
885
886 EXPECT_EQ(result.size(), N);
887 for (size_t i = 0; i < N; ++i)
888 EXPECT_EQ(result[i], static_cast<int>(2 * i));
889}
890
891TEST_F(CompleteGroup, zip_transform_eq_success)
892{
893 auto result = zip_transform_eq([](auto t) {
894 return get<0>(t) * get<1>(t);
895 }, l1, l2);
896
897 EXPECT_EQ(result.size(), N);
898 for (size_t i = 0; i < N; ++i)
899 EXPECT_EQ(result[i], static_cast<int>(i * i));
900}
901
902TEST_F(InCompleteGroup, zip_transform_eq_throws)
903{
904 EXPECT_THROW(
905 zip_transform_eq([](auto t) { return get<0>(t); }, l1, l2),
906 length_error
907 );
908}
909
910TEST(ZipTransform, empty_containers)
911{
912 DynList<int> empty1, empty2;
913 auto result = zip_transform([](auto t) { return get<0>(t); }, empty1, empty2);
914 EXPECT_TRUE(result.empty());
915}
916
917// ---------- Issue 17: zip_for_each_indexed ----------
918
919TEST_F(CompleteGroup, zip_for_each_indexed_basic)
920{
921 vector<size_t> indices;
922 vector<int> values;
923
924 zip_for_each_indexed([&](size_t idx, auto t) {
925 indices.push_back(idx);
926 values.push_back(get<0>(t));
927 }, l1, l2);
928
929 EXPECT_EQ(indices.size(), N);
930 EXPECT_EQ(values.size(), N);
931
932 for (size_t i = 0; i < N; ++i)
933 {
934 EXPECT_EQ(indices[i], i);
935 EXPECT_EQ(values[i], static_cast<int>(i));
936 }
937}
938
939TEST_F(CompleteGroup, zip_for_each_indexed_verify_tuple)
940{
941 zip_for_each_indexed([](size_t idx, auto t) {
942 EXPECT_EQ(get<0>(t), static_cast<int>(idx));
943 EXPECT_EQ(get<1>(t), static_cast<int>(idx));
944 EXPECT_EQ(get<2>(t), to_string(idx));
945 }, l1, l2, l3);
946}
947
948TEST_F(CompleteGroup, zip_for_each_indexed_eq_success)
949{
950 size_t count = 0;
951 EXPECT_NO_THROW(
952 zip_for_each_indexed_eq([&count](size_t idx, [[maybe_unused]] auto t) {
953 EXPECT_EQ(idx, count);
954 ++count;
955 }, l1, l2, l3)
956 );
957 EXPECT_EQ(count, N);
958}
959
960TEST_F(InCompleteGroup, zip_for_each_indexed_eq_throws)
961{
962 EXPECT_THROW(
963 zip_for_each_indexed_eq([](size_t, auto) {}, l1, l2),
964 length_error
965 );
966}
967
968TEST(ZipForEachIndexed, empty_containers)
969{
970 DynList<int> empty1, empty2;
971 size_t count = 0;
972 zip_for_each_indexed([&count](size_t, auto) { ++count; }, empty1, empty2);
973 EXPECT_EQ(count, 0);
974}
975
976// ---------- Issue 19: zip_take / zip_drop ----------
977
978TEST_F(CompleteGroup, zip_take_basic)
979{
980 auto result = zip_take(3, l1, l2, l3);
981
982 EXPECT_EQ(result.size(), 3);
983
984 size_t i = 0;
985 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
986 {
987 auto t = it.get_curr();
988 EXPECT_EQ(get<0>(t), static_cast<int>(i));
989 EXPECT_EQ(get<1>(t), static_cast<int>(i));
990 EXPECT_EQ(get<2>(t), to_string(i));
991 }
992}
993
994TEST_F(CompleteGroup, zip_take_more_than_available)
995{
996 auto result = zip_take(100, l1, l2); // Request more than N elements
997 EXPECT_EQ(result.size(), N); // Should only get N
998}
999
1000TEST_F(CompleteGroup, zip_take_zero)
1001{
1002 auto result = zip_take(0, l1, l2);
1003 EXPECT_TRUE(result.is_empty());
1004}
1005
1006TEST_F(CompleteGroup, zip_drop_basic)
1007{
1008 auto result = zip_drop(2, l1, l2, l3);
1009
1010 EXPECT_EQ(result.size(), N - 2);
1011
1012 size_t i = 2; // Start from index 2
1013 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
1014 {
1015 auto t = it.get_curr();
1016 EXPECT_EQ(get<0>(t), static_cast<int>(i));
1017 EXPECT_EQ(get<1>(t), static_cast<int>(i));
1018 EXPECT_EQ(get<2>(t), to_string(i));
1019 }
1020}
1021
1022TEST_F(CompleteGroup, zip_drop_all)
1023{
1024 auto result = zip_drop(N, l1, l2);
1025 EXPECT_TRUE(result.is_empty());
1026}
1027
1028TEST_F(CompleteGroup, zip_drop_more_than_available)
1029{
1030 auto result = zip_drop(100, l1, l2);
1031 EXPECT_TRUE(result.is_empty());
1032}
1033
1034TEST_F(CompleteGroup, zip_drop_zero)
1035{
1036 auto result = zip_drop(0, l1, l2);
1037 EXPECT_EQ(result.size(), N);
1038}
1039
1040TEST_F(CompleteGroup, zip_take_while_basic)
1041{
1042 // Take while first element < 3
1043 auto result = zip_take_while([](auto t) { return get<0>(t) < 3; }, l1, l2, l3);
1044
1045 EXPECT_EQ(result.size(), 3); // Elements 0, 1, 2
1046
1047 size_t i = 0;
1048 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
1049 {
1050 auto t = it.get_curr();
1051 EXPECT_EQ(get<0>(t), static_cast<int>(i));
1052 EXPECT_LT(get<0>(t), 3);
1053 }
1054}
1055
1056TEST_F(CompleteGroup, zip_take_while_none)
1057{
1058 // Predicate immediately false
1059 auto result = zip_take_while([](auto t) { return get<0>(t) < 0; }, l1, l2);
1060 EXPECT_TRUE(result.is_empty());
1061}
1062
1063TEST_F(CompleteGroup, zip_take_while_all)
1064{
1065 // Predicate always true
1066 auto result = zip_take_while([](auto t) { return get<0>(t) < 100; }, l1, l2);
1067 EXPECT_EQ(result.size(), N);
1068}
1069
1070TEST_F(CompleteGroup, zip_drop_while_basic)
1071{
1072 // Drop while first element < 3, then collect the rest
1073 auto result = zip_drop_while([](auto t) { return get<0>(t) < 3; }, l1, l2, l3);
1074
1075 EXPECT_EQ(result.size(), N - 3); // Elements 3, 4
1076
1077 size_t i = 3;
1078 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
1079 {
1080 auto t = it.get_curr();
1081 EXPECT_EQ(get<0>(t), static_cast<int>(i));
1082 }
1083}
1084
1085TEST_F(CompleteGroup, zip_drop_while_none)
1086{
1087 // Predicate immediately false - drop nothing
1088 auto result = zip_drop_while([](auto t) { return get<0>(t) < 0; }, l1, l2);
1089 EXPECT_EQ(result.size(), N);
1090}
1091
1092TEST_F(CompleteGroup, zip_drop_while_all)
1093{
1094 // Predicate always true - drop all
1095 auto result = zip_drop_while([](auto t) { return get<0>(t) < 100; }, l1, l2);
1096 EXPECT_TRUE(result.is_empty());
1097}
1098
1099TEST(ZipTakeDrop, empty_containers)
1100{
1101 DynList<int> empty1, empty2;
1102
1103 EXPECT_TRUE(zip_take(5, empty1, empty2).is_empty());
1104 EXPECT_TRUE(zip_drop(5, empty1, empty2).is_empty());
1105 EXPECT_TRUE(zip_take_while([](auto) { return true; }, empty1, empty2).is_empty());
1106 EXPECT_TRUE(zip_drop_while([](auto) { return true; }, empty1, empty2).is_empty());
1107}
1108
1109// ---------- Issue 20: Tuple helpers with index_sequence ----------
1110
1111TEST(TupleHelpers, for_each_in_tuple_basic)
1112{
1113 auto t = make_tuple(1, 2.5, string("hello"));
1114
1115 vector<string> collected;
1116 for_each_in_tuple([&collected](auto &elem) {
1117 ostringstream oss;
1118 oss << elem;
1119 collected.push_back(oss.str());
1120 }, t);
1121
1122 EXPECT_EQ(collected.size(), 3);
1123 EXPECT_EQ(collected[0], "1");
1124 EXPECT_EQ(collected[1], "2.5");
1125 EXPECT_EQ(collected[2], "hello");
1126}
1127
1128TEST(TupleHelpers, for_each_in_tuple_modify)
1129{
1130 auto t = make_tuple(1, 2, 3);
1131
1132 for_each_in_tuple([](auto &elem) { elem *= 2; }, t);
1133
1134 EXPECT_EQ(get<0>(t), 2);
1135 EXPECT_EQ(get<1>(t), 4);
1136 EXPECT_EQ(get<2>(t), 6);
1137}
1138
1139TEST(TupleHelpers, for_each_in_tuple_empty)
1140{
1141 auto t = make_tuple();
1142 size_t count = 0;
1143 for_each_in_tuple([&count](auto &) { ++count; }, t);
1144 EXPECT_EQ(count, 0);
1145}
1146
1147TEST(TupleHelpers, transform_tuple_basic)
1148{
1149 auto t = make_tuple(1, 2, 3);
1150
1151 auto result = transform_tuple([](auto x) { return x * 10; }, t);
1152
1153 EXPECT_EQ(get<0>(result), 10);
1154 EXPECT_EQ(get<1>(result), 20);
1155 EXPECT_EQ(get<2>(result), 30);
1156}
1157
1158TEST(TupleHelpers, transform_tuple_type_change)
1159{
1160 auto t = make_tuple(1, 2, 3);
1161
1162 // Transform int -> string
1163 auto result = transform_tuple([](auto x) { return to_string(x); }, t);
1164
1165 static_assert(is_same_v<decay_t<decltype(get<0>(result))>, string>);
1166 EXPECT_EQ(get<0>(result), "1");
1167 EXPECT_EQ(get<1>(result), "2");
1168 EXPECT_EQ(get<2>(result), "3");
1169}
1170
1171TEST(TupleHelpers, transform_tuple_heterogeneous)
1172{
1173 auto t = make_tuple(1, 2.5, string("hi"));
1174
1175 // Double each value (works differently for each type)
1176 auto result = transform_tuple([](auto x) {
1177 if constexpr (is_same_v<decay_t<decltype(x)>, string>)
1178 return x + x;
1179 else
1180 return x * 2;
1181 }, t);
1182
1183 EXPECT_EQ(get<0>(result), 2);
1184 EXPECT_DOUBLE_EQ(get<1>(result), 5.0);
1185 EXPECT_EQ(get<2>(result), "hihi");
1186}
1187
1188TEST(TupleHelpers, all_of_tuple_true)
1189{
1190 auto t = make_tuple(2, 4, 6, 8);
1191
1192 bool result = all_of_tuple([](auto x) { return x % 2 == 0; }, t);
1193 EXPECT_TRUE(result);
1194}
1195
1196TEST(TupleHelpers, all_of_tuple_false)
1197{
1198 auto t = make_tuple(2, 4, 5, 8); // 5 is odd
1199
1200 bool result = all_of_tuple([](auto x) { return x % 2 == 0; }, t);
1201 EXPECT_FALSE(result);
1202}
1203
1204TEST(TupleHelpers, all_of_tuple_empty)
1205{
1206 auto t = make_tuple();
1207 // Empty tuple should return true (vacuous truth)
1208 bool result = all_of_tuple([](auto) { return false; }, t);
1209 EXPECT_TRUE(result);
1210}
1211
1212TEST(TupleHelpers, any_of_tuple_true)
1213{
1214 auto t = make_tuple(1, 3, 4, 7); // 4 is even
1215
1216 bool result = any_of_tuple([](auto x) { return x % 2 == 0; }, t);
1217 EXPECT_TRUE(result);
1218}
1219
1220TEST(TupleHelpers, any_of_tuple_false)
1221{
1222 auto t = make_tuple(1, 3, 5, 7); // All odd
1223
1224 bool result = any_of_tuple([](auto x) { return x % 2 == 0; }, t);
1225 EXPECT_FALSE(result);
1226}
1227
1228TEST(TupleHelpers, any_of_tuple_empty)
1229{
1230 auto t = make_tuple();
1231 // Empty tuple should return false
1232 bool result = any_of_tuple([](auto) { return true; }, t);
1233 EXPECT_FALSE(result);
1234}
1235
1236TEST(TupleHelpers, all_any_combined)
1237{
1238 auto t = make_tuple(10, 20, 30, 40, 50);
1239
1240 // All > 0
1241 EXPECT_TRUE(all_of_tuple([](auto x) { return x > 0; }, t));
1242
1243 // Any > 45
1244 EXPECT_TRUE(any_of_tuple([](auto x) { return x > 45; }, t));
1245
1246 // None > 100
1247 EXPECT_FALSE(any_of_tuple([](auto x) { return x > 100; }, t));
1248
1249 // Not all > 25
1250 EXPECT_FALSE(all_of_tuple([](auto x) { return x > 25; }, t));
1251}
1252
1253// Stress test for new features
1254TEST(StressTestNewFeatures, large_containers)
1255{
1256 const size_t SIZE = 1000;
1257 DynList<int> l1 = range<int>(0, SIZE - 1);
1258 DynList<int> l2 = range<int>(0, SIZE - 1);
1259
1260 // zip_transform
1261 auto transformed = zip_transform([](auto t) {
1262 return get<0>(t) + get<1>(t);
1263 }, l1, l2);
1264 EXPECT_EQ(transformed.size(), SIZE);
1265 for (size_t i = 0; i < SIZE; ++i)
1266 EXPECT_EQ(transformed[i], static_cast<int>(2 * i));
1267
1268 // zip_for_each_indexed
1269 size_t sum_indices = 0;
1270 zip_for_each_indexed([&sum_indices](size_t idx, auto) {
1271 sum_indices += idx;
1272 }, l1, l2);
1273 EXPECT_EQ(sum_indices, SIZE * (SIZE - 1) / 2);
1274
1275 // zip_take
1276 auto taken = zip_take(100, l1, l2);
1277 EXPECT_EQ(taken.size(), 100);
1278
1279 // zip_drop
1280 auto dropped = zip_drop(900, l1, l2);
1281 EXPECT_EQ(dropped.size(), 100);
1282
1283 // zip_take_while
1284 auto taken_while = zip_take_while([](auto t) { return get<0>(t) < 500; }, l1, l2);
1285 EXPECT_EQ(taken_while.size(), 500);
1286
1287 // zip_drop_while
1288 auto dropped_while = zip_drop_while([](auto t) { return get<0>(t) < 500; }, l1, l2);
1289 EXPECT_EQ(dropped_while.size(), 500);
1290}
1291
1292// ============================================================================
1293// Additional edge case tests
1294// ============================================================================
1295
1296// Test that original containers are not modified by zip operations
1297TEST(Immutability, containers_not_modified)
1298{
1299 DynList<int> original1 = { 1, 2, 3, 4, 5 };
1300 DynList<int> original2 = { 10, 20, 30, 40, 50 };
1301
1302 // Save copies
1303 DynList<int> copy1 = original1;
1304 DynList<int> copy2 = original2;
1305
1306 // Perform various zip operations
1307 auto zipped = t_zip(original1, original2);
1308 auto mapped = zip_maps<int>([](auto t) { return get<0>(t) + get<1>(t); }, original1, original2);
1309 auto filtered = zip_filter([](auto t) { return get<0>(t) > 2; }, original1, original2);
1310 zip_for_each([](auto) {}, original1, original2);
1311 [[maybe_unused]] auto folded = zip_foldl(0, [](auto acc, auto t) { return acc + get<0>(t); }, original1, original2);
1312
1313 // Verify originals unchanged
1314 EXPECT_EQ(original1, copy1);
1315 EXPECT_EQ(original2, copy2);
1316}
1317
1318// Test zip_cmp with empty containers
1319TEST(ZipCmp, empty_containers)
1320{
1321 DynList<int> empty1, empty2;
1322
1323 // All comparisons on empty containers should return true (vacuous truth)
1324 EXPECT_TRUE(zip_cmp([](auto, auto) { return true; }, empty1, empty2));
1325 EXPECT_TRUE(zip_cmp([](auto, auto) { return false; }, empty1, empty2));
1326}
1327
1328// Test zip_cmp with single element
1329TEST(ZipCmp, single_element)
1330{
1331 DynList<int> l1 = { 5 };
1332 DynList<int> l2 = { 5 };
1333 DynList<int> l3 = { 10 };
1334
1335 EXPECT_TRUE(zip_cmp([](auto a, auto b) { return a == b; }, l1, l2));
1336 EXPECT_FALSE(zip_cmp([](auto a, auto b) { return a == b; }, l1, l3));
1337}
1338
1339// Test ZipIterator copy semantics
1340TEST(ZipIteratorSemantics, copy_iterator)
1341{
1342 DynList<int> l1 = { 1, 2, 3, 4, 5 };
1343 DynList<int> l2 = { 10, 20, 30, 40, 50 };
1344
1345 auto it1 = zip_it(l1, l2);
1346 it1.next_ne();
1347 it1.next_ne(); // Now at position 2
1348
1349 auto it2 = it1; // Copy
1350
1351 // Both should be at same position
1352 EXPECT_EQ(get<0>(it1.get_curr_ne()), get<0>(it2.get_curr_ne()));
1353 EXPECT_EQ(get<1>(it1.get_curr_ne()), get<1>(it2.get_curr_ne()));
1354
1355 // Advance original, copy should stay
1356 it1.next_ne();
1357 EXPECT_NE(get<0>(it1.get_curr_ne()), get<0>(it2.get_curr_ne()));
1358}
1359
1360// Test single container with all functional operations
1361TEST(SingleContainer, functional_operations)
1362{
1363 DynList<int> l = { 1, 2, 3, 4, 5 };
1364
1365 // zip_traverse
1366 EXPECT_TRUE(zip_traverse([](auto t) { return get<0>(t) <= 5; }, l));
1367 EXPECT_FALSE(zip_traverse([](auto t) { return get<0>(t) < 3; }, l));
1368
1369 // zip_all
1370 EXPECT_TRUE(zip_all([](auto t) { return get<0>(t) <= 5; }, l));
1371
1372 // zip_exists
1373 EXPECT_TRUE(zip_exists([](auto t) { return get<0>(t) == 3; }, l));
1374 EXPECT_FALSE(zip_exists([](auto t) { return get<0>(t) == 99; }, l));
1375
1376 // zip_find_index
1377 EXPECT_EQ(zip_find_index([](auto t) { return get<0>(t) == 3; }, l), 2);
1378 EXPECT_EQ(zip_find_index([](auto t) { return get<0>(t) == 99; }, l), 5);
1379
1380 // zip_foldl
1381 auto sum = zip_foldl(0, [](auto acc, auto t) { return acc + get<0>(t); }, l);
1382 EXPECT_EQ(sum, 15);
1383
1384 // zip_filter
1385 auto filtered = zip_filter([](auto t) { return get<0>(t) % 2 == 0; }, l);
1386 EXPECT_EQ(filtered.size(), 2); // 2 and 4
1387
1388 // zip_partition
1389 auto part = zip_partition([](auto t) { return get<0>(t) < 3; }, l);
1390 EXPECT_EQ(get<1>(part), 2); // 1, 2
1391 EXPECT_EQ(get<3>(part), 3); // 3, 4, 5
1392}
1393
1394// Test const correctness
1395TEST(ConstCorrectness, const_containers)
1396{
1397 const DynList<int> cl1 = { 1, 2, 3 };
1398 const DynList<int> cl2 = { 10, 20, 30 };
1399
1400 // All operations should work with const containers
1401 auto zipped = t_zip(cl1, cl2);
1402 EXPECT_EQ(zipped.size(), 3);
1403
1404 EXPECT_TRUE(equal_length(cl1, cl2));
1405
1406 auto mapped = zip_maps<int>([](auto t) { return get<0>(t); }, cl1, cl2);
1407 EXPECT_EQ(mapped.size(), 3);
1408
1409 size_t count = 0;
1410 zip_for_each([&count](auto) { ++count; }, cl1, cl2);
1411 EXPECT_EQ(count, 3);
1412}
1413
1414// Test very large number of containers (up to 6)
1415TEST(ManyContainers, six_containers)
1416{
1417 DynList<int> c1 = { 1, 2 };
1418 DynList<int> c2 = { 10, 20 };
1419 DynList<int> c3 = { 100, 200 };
1420 DynList<int> c4 = { 1000, 2000 };
1421 DynList<int> c5 = { 10000, 20000 };
1422 DynList<int> c6 = { 100000, 200000 };
1423
1424 size_t count = 0;
1425 for (auto it = zip_it(c1, c2, c3, c4, c5, c6); it.has_curr(); it.next_ne())
1426 {
1427 auto t = it.get_curr_ne();
1428 if (count == 0)
1429 {
1430 EXPECT_EQ(get<0>(t), 1);
1431 EXPECT_EQ(get<1>(t), 10);
1432 EXPECT_EQ(get<2>(t), 100);
1433 EXPECT_EQ(get<3>(t), 1000);
1434 EXPECT_EQ(get<4>(t), 10000);
1435 EXPECT_EQ(get<5>(t), 100000);
1436 }
1437 ++count;
1438 }
1439 EXPECT_EQ(count, 2);
1440}
1441
1442// Test zip operations with rvalue containers (temporary containers)
1443TEST(RvalueContainers, temporary_containers)
1444{
1445 // This tests that zip can work with inline-constructed containers
1446 // when the containers are captured by const ref
1447
1448 auto sum = zip_foldl(0, [](auto acc, auto t) { return acc + get<0>(t) + get<1>(t); },
1449 DynList<int>{1, 2, 3}, DynList<int>{10, 20, 30});
1450 EXPECT_EQ(sum, 66); // (1+10) + (2+20) + (3+30) = 66
1451}
1452
1453// Test t_zip with very short containers
1454TEST(ShortContainers, single_element)
1455{
1456 DynList<int> l1 = { 42 };
1457 DynList<string> l2 = { "hello" };
1458
1459 auto zipped = t_zip(l1, l2);
1460 EXPECT_EQ(zipped.size(), 1);
1461
1462 auto t = zipped.get_first();
1463 EXPECT_EQ(get<0>(t), 42);
1464 EXPECT_EQ(get<1>(t), "hello");
1465}
1466
1467// Test enum_zip with single container
1468TEST(EnumZipSingle, single_container)
1469{
1470 DynList<string> l = { "a", "b", "c" };
1471
1472 size_t count = 0;
1473 for (auto it = enum_zip_it(l); it.has_curr(); it.next_ne(), ++count)
1474 {
1475 auto t = it.get_curr_ne();
1476 EXPECT_EQ(get<1>(t), count); // Index is second element for single container
1477 EXPECT_EQ(get<0>(t), string(1, 'a' + count));
1478 }
1479 EXPECT_EQ(count, 3);
1480}
1481
1482// Test t_unzip with single-element tuples
1483TEST(TUnzip, single_element_tuples)
1484{
1485 DynList<tuple<int>> l = { make_tuple(1), make_tuple(2), make_tuple(3) };
1486
1487 auto result = t_unzip(l);
1488 EXPECT_EQ(get<0>(result), DynList<int>({1, 2, 3}));
1489}
1490
1491// Test t_unzip with empty list
1492TEST(TUnzip, empty_list)
1493{
1495
1496 auto result = t_unzip(l);
1497 EXPECT_TRUE(get<0>(result).is_empty());
1498 EXPECT_TRUE(get<1>(result).is_empty());
1499}
1500
1501// Test zip_cmp with 4 containers
1502TEST(ZipCmp, four_containers)
1503{
1504 DynList<int> l1 = { 1, 2, 3 };
1505 DynList<int> l2 = { 1, 2, 3 };
1506 DynList<int> l3 = { 1, 2, 3 };
1507 DynList<int> l4 = { 1, 2, 3 };
1508
1509 EXPECT_TRUE(zip_cmp([](auto a, auto b) { return a == b; }, l1, l2, l3, l4));
1510
1511 DynList<int> l5 = { 1, 2, 4 }; // Different at position 2
1512 EXPECT_FALSE(zip_cmp([](auto a, auto b) { return a == b; }, l1, l2, l3, l5));
1513}
1514
1515// Test that next() throws on empty after exhaustion
1516TEST(BoundsChecking, next_throws_after_exhaustion)
1517{
1518 DynList<int> l1 = { 1 };
1519 DynList<int> l2 = { 10 };
1520
1521 auto it = zip_it(l1, l2);
1522 EXPECT_TRUE(it.has_curr());
1523 it.next();
1524 EXPECT_FALSE(it.has_curr());
1525 EXPECT_THROW(it.next(), std::overflow_error);
1526}
1527
1528// Test that get_curr() throws when not has_curr
1529TEST(BoundsChecking, get_curr_throws)
1530{
1531 DynList<int> l1 = { 1 };
1532 DynList<int> l2 = { 10 };
1533
1534 auto it = zip_it(l1, l2);
1535 it.next();
1536 EXPECT_FALSE(it.has_curr());
1537 EXPECT_THROW(it.get_curr(), std::overflow_error);
1538}
1539
1540// ============================================================================
1541// Tests for new functions: zip_none, zip_count, zip_length, zip_find_first, etc.
1542// ============================================================================
1543
1544// ============================================================================
1545// Tests for zip_all_short, zip_forall, zip_forall_short, zip_any
1546// ============================================================================
1547
1548TEST_F(CompleteGroup, zip_all_short_true)
1549{
1550 EXPECT_TRUE(zip_all_short([](auto t) { return get<0>(t) >= 0; }, l1, l2));
1551}
1552
1553TEST_F(CompleteGroup, zip_all_short_false)
1554{
1555 EXPECT_FALSE(zip_all_short([](auto t) { return get<0>(t) < 3; }, l1, l2));
1556}
1557
1558TEST_F(InCompleteGroup, zip_all_short_unequal_lengths)
1559{
1560 // zip_all_short should work on unequal lengths (uses minimum)
1561 // All elements in the intersection satisfy x >= 0
1562 EXPECT_TRUE(zip_all_short([](auto t) { return get<0>(t) >= 0; }, l1, l2));
1563}
1564
1565TEST_F(InCompleteGroup, zip_all_vs_zip_all_short)
1566{
1567 // zip_all returns false on unequal lengths (even if predicate satisfied)
1568 EXPECT_FALSE(zip_all([](auto t) { return get<0>(t) >= 0; }, l1, l2));
1569
1570 // zip_all_short returns true (doesn't check lengths)
1571 EXPECT_TRUE(zip_all_short([](auto t) { return get<0>(t) >= 0; }, l1, l2));
1572}
1573
1574TEST(ZipAllShort, empty_containers)
1575{
1576 DynList<int> e1, e2;
1577 // Vacuously true
1578 EXPECT_TRUE(zip_all_short([](auto) { return false; }, e1, e2));
1579}
1580
1581TEST_F(CompleteGroup, zip_forall_alias)
1582{
1583 // zip_forall is alias for zip_all
1584 EXPECT_EQ(
1585 zip_forall([](auto t) { return get<0>(t) >= 0; }, l1, l2),
1586 zip_all([](auto t) { return get<0>(t) >= 0; }, l1, l2)
1587 );
1588}
1589
1590TEST_F(CompleteGroup, zip_forall_short_alias)
1591{
1592 // zip_forall_short is alias for zip_all_short
1593 EXPECT_EQ(
1594 zip_forall_short([](auto t) { return get<0>(t) >= 0; }, l1, l2),
1595 zip_all_short([](auto t) { return get<0>(t) >= 0; }, l1, l2)
1596 );
1597}
1598
1599TEST_F(CompleteGroup, zip_any_alias)
1600{
1601 // zip_any is alias for zip_exists
1602 EXPECT_EQ(
1603 zip_any([](auto t) { return get<0>(t) == 3; }, l1, l2),
1604 zip_exists([](auto t) { return get<0>(t) == 3; }, l1, l2)
1605 );
1606}
1607
1608TEST_F(CompleteGroup, zip_any_true)
1609{
1610 EXPECT_TRUE(zip_any([](auto t) { return get<0>(t) == 3; }, l1, l2));
1611}
1612
1613TEST_F(CompleteGroup, zip_any_false)
1614{
1615 EXPECT_FALSE(zip_any([](auto t) { return get<0>(t) == 99; }, l1, l2));
1616}
1617
1618TEST(ZipAny, empty_containers)
1619{
1620 DynList<int> e1, e2;
1621 // No elements, so any is false
1622 EXPECT_FALSE(zip_any([](auto) { return true; }, e1, e2));
1623}
1624
1625TEST_F(CompleteGroup, zip_none_true)
1626{
1627 // No element > 100
1628 EXPECT_TRUE(zip_none([](auto t) { return get<0>(t) > 100; }, l1, l2));
1629}
1630
1631TEST_F(CompleteGroup, zip_none_false)
1632{
1633 // Some elements are >= 0
1634 EXPECT_FALSE(zip_none([](auto t) { return get<0>(t) >= 0; }, l1, l2));
1635}
1636
1637TEST(ZipNone, empty_containers)
1638{
1639 DynList<int> e1, e2;
1640 // Empty = vacuously true
1641 EXPECT_TRUE(zip_none([](auto) { return true; }, e1, e2));
1642}
1643
1644TEST_F(CompleteGroup, zip_count_all)
1645{
1646 // Count all elements (all satisfy x >= 0)
1647 EXPECT_EQ(zip_count([](auto t) { return get<0>(t) >= 0; }, l1, l2), N);
1648}
1649
1650TEST_F(CompleteGroup, zip_count_some)
1651{
1652 // Count elements where first < 3
1653 EXPECT_EQ(zip_count([](auto t) { return get<0>(t) < 3; }, l1, l2), 3u);
1654}
1655
1656TEST_F(CompleteGroup, zip_count_none)
1657{
1658 // Count elements > 100 (none)
1659 EXPECT_EQ(zip_count([](auto t) { return get<0>(t) > 100; }, l1, l2), 0u);
1660}
1661
1662TEST(ZipCount, empty_containers)
1663{
1664 DynList<int> e1, e2;
1665 EXPECT_EQ(zip_count([](auto) { return true; }, e1, e2), 0u);
1666}
1667
1668TEST_F(CompleteGroup, zip_length_basic)
1669{
1670 EXPECT_EQ(zip_length(l1, l2, l3), N);
1671}
1672
1673TEST_F(InCompleteGroup, zip_length_unequal)
1674{
1675 // l2 has only 4 elements, l1 and l3 have 5
1676 EXPECT_EQ(zip_length(l1, l2, l3), 4u);
1677}
1678
1679TEST(ZipLength, empty_containers)
1680{
1681 DynList<int> e1, e2;
1682 EXPECT_EQ(zip_length(e1, e2), 0u);
1683}
1684
1685TEST(ZipLength, single_container)
1686{
1687 DynList<int> l = { 1, 2, 3, 4, 5 };
1688 EXPECT_EQ(zip_length(l), 5u);
1689}
1690
1691TEST_F(CompleteGroup, zip_find_first_found)
1692{
1693 auto [t, found] = zip_find_first([](auto t) { return get<0>(t) == 3; }, l1, l2, l3);
1694
1695 EXPECT_TRUE(found);
1696 EXPECT_EQ(get<0>(t), 3);
1697 EXPECT_EQ(get<1>(t), 3);
1698 EXPECT_EQ(get<2>(t), "3");
1699}
1700
1701TEST_F(CompleteGroup, zip_find_first_not_found)
1702{
1703 auto [t, found] = zip_find_first([](auto t) { return get<0>(t) == 99; }, l1, l2);
1704
1705 EXPECT_FALSE(found);
1706}
1707
1708TEST_F(CompleteGroup, zip_find_first_returns_first_match)
1709{
1710 // Multiple elements satisfy x >= 2, should return the first (index 2)
1711 auto [t, found] = zip_find_first([](auto t) { return get<0>(t) >= 2; }, l1, l2);
1712
1713 EXPECT_TRUE(found);
1714 EXPECT_EQ(get<0>(t), 2); // First match
1715}
1716
1717TEST(ZipFindFirst, empty_containers)
1718{
1719 DynList<int> e1, e2;
1720 auto [t, found] = zip_find_first([](auto) { return true; }, e1, e2);
1721 EXPECT_FALSE(found);
1722}
1723
1724TEST_F(CompleteGroup, zip_find_last_found)
1725{
1726 // Find last element where x < 4
1727 auto [t, found] = zip_find_last([](auto t) { return get<0>(t) < 4; }, l1, l2, l3);
1728
1729 EXPECT_TRUE(found);
1730 EXPECT_EQ(get<0>(t), 3); // Last element < 4 is 3
1731}
1732
1733TEST_F(CompleteGroup, zip_find_last_not_found)
1734{
1735 auto [t, found] = zip_find_last([](auto t) { return get<0>(t) > 100; }, l1, l2);
1736
1737 EXPECT_FALSE(found);
1738}
1739
1740TEST_F(CompleteGroup, zip_find_last_returns_last_match)
1741{
1742 // All elements satisfy x >= 0, should return the last (index N-1)
1743 auto [t, found] = zip_find_last([](auto t) { return get<0>(t) >= 0; }, l1, l2);
1744
1745 EXPECT_TRUE(found);
1746 EXPECT_EQ(get<0>(t), static_cast<int>(N - 1));
1747}
1748
1749TEST(ZipFindLast, empty_containers)
1750{
1751 DynList<int> e1, e2;
1752 auto [t, found] = zip_find_last([](auto) { return true; }, e1, e2);
1753 EXPECT_FALSE(found);
1754}
1755
1756TEST_F(CompleteGroup, zip_nth_valid)
1757{
1758 auto [t, found] = zip_nth(2, l1, l2, l3);
1759
1760 EXPECT_TRUE(found);
1761 EXPECT_EQ(get<0>(t), 2);
1762 EXPECT_EQ(get<1>(t), 2);
1763 EXPECT_EQ(get<2>(t), "2");
1764}
1765
1766TEST_F(CompleteGroup, zip_nth_first)
1767{
1768 auto [t, found] = zip_nth(0, l1, l2);
1769
1770 EXPECT_TRUE(found);
1771 EXPECT_EQ(get<0>(t), 0);
1772 EXPECT_EQ(get<1>(t), 0);
1773}
1774
1775TEST_F(CompleteGroup, zip_nth_last)
1776{
1777 auto [t, found] = zip_nth(N - 1, l1, l2);
1778
1779 EXPECT_TRUE(found);
1780 EXPECT_EQ(get<0>(t), static_cast<int>(N - 1));
1781}
1782
1783TEST_F(CompleteGroup, zip_nth_out_of_range)
1784{
1785 auto [t, found] = zip_nth(N + 10, l1, l2);
1786
1787 EXPECT_FALSE(found);
1788}
1789
1790TEST(ZipNth, empty_containers)
1791{
1792 DynList<int> e1, e2;
1793 auto [t, found] = zip_nth(0, e1, e2);
1794 EXPECT_FALSE(found);
1795}
1796
1797TEST_F(CompleteGroup, zip_first_basic)
1798{
1799 auto [t, found] = zip_first(l1, l2, l3);
1800
1801 EXPECT_TRUE(found);
1802 EXPECT_EQ(get<0>(t), 0);
1803 EXPECT_EQ(get<1>(t), 0);
1804 EXPECT_EQ(get<2>(t), "0");
1805}
1806
1807TEST(ZipFirst, empty_containers)
1808{
1809 DynList<int> e1, e2;
1810 auto [t, found] = zip_first(e1, e2);
1811 EXPECT_FALSE(found);
1812}
1813
1814// Test Tuple_Type alias
1815TEST_F(CompleteGroup, tuple_type_alias)
1816{
1818 using ExpectedType = std::tuple<int, int, string>;
1819
1820 static_assert(std::is_same_v<ZipIt::Tuple_Type, ExpectedType>,
1821 "Tuple_Type should be tuple<int, int, string>");
1822
1823 // Verify we can use it to declare variables
1824 ZipIt::Tuple_Type t = std::make_tuple(1, 2, "test");
1825 EXPECT_EQ(get<0>(t), 1);
1826 EXPECT_EQ(get<1>(t), 2);
1827 EXPECT_EQ(get<2>(t), "test");
1828}
1829
1830// Test Item_Type alias
1831TEST(TypeAliases, item_type_alias)
1832{
1833 using ZipIt = ZipIterator<DynList<int>>;
1834 static_assert(std::is_same_v<ZipIt::Item_Type, int>,
1835 "Item_Type should be int for single container");
1836}
1837
1838// ============================================================================
1839// Tests for zip_maps_eq, zip_maps_if_eq, zip_foldl_eq, zip_map, zip_map_eq
1840// ============================================================================
1841
1842TEST_F(CompleteGroup, zip_maps_eq_success)
1843{
1844 auto result = zip_maps_eq<string>([](auto t) {
1845 return to_string(get<0>(t)) + "-" + to_string(get<1>(t));
1846 }, l1, l2);
1847
1848 EXPECT_EQ(result.size(), N);
1849 EXPECT_EQ(result.get_first(), "0-0");
1850}
1851
1852TEST_F(InCompleteGroup, zip_maps_eq_throws)
1853{
1854 EXPECT_THROW(
1855 zip_maps_eq<int>([](auto t) { return get<0>(t); }, l1, l2),
1856 length_error
1857 );
1858}
1859
1860TEST_F(CompleteGroup, zip_maps_if_eq_success)
1861{
1862 // Map only elements where first > 1
1863 auto result = zip_maps_if_eq<int>(
1864 [](auto t) { return get<0>(t) > 1; },
1865 [](auto t) { return get<0>(t) * 10; },
1866 l1, l2
1867 );
1868
1869 EXPECT_EQ(result.size(), N - 2); // 2, 3, 4 -> 3 elements
1870 EXPECT_EQ(result.get_first(), 20);
1871}
1872
1873TEST_F(InCompleteGroup, zip_maps_if_eq_throws)
1874{
1875 EXPECT_THROW(
1876 zip_maps_if_eq<int>(
1877 [](auto) { return true; },
1878 [](auto t) { return get<0>(t); },
1879 l1, l2
1880 ),
1881 length_error
1882 );
1883}
1884
1885TEST_F(CompleteGroup, zip_foldl_eq_success)
1886{
1887 auto sum = zip_foldl_eq(0, [](auto acc, auto t) {
1888 return acc + get<0>(t) + get<1>(t);
1889 }, l1, l2);
1890
1891 EXPECT_EQ(sum, static_cast<int>(N * (N - 1))); // 2 * sum(0..N-1)
1892}
1893
1894TEST_F(InCompleteGroup, zip_foldl_eq_throws)
1895{
1896 EXPECT_THROW(
1897 (void) zip_foldl_eq(0, [](auto acc, auto t) { return acc + get<0>(t); }, l1, l2),
1898 length_error
1899 );
1900}
1901
1902TEST_F(CompleteGroup, zip_map_auto_deduce)
1903{
1904 // Auto-deduce return type (string)
1905 auto result = zip_map([](auto t) {
1906 return to_string(get<0>(t)) + ":" + get<2>(t);
1907 }, l1, l2, l3);
1908
1909 EXPECT_EQ(result.size(), N);
1910 EXPECT_EQ(result.get_first(), "0:0");
1911
1912 // Verify the type is DynList<string>
1913 static_assert(std::is_same_v<decltype(result), DynList<string>>,
1914 "zip_map should return DynList<string>");
1915}
1916
1917TEST_F(CompleteGroup, zip_map_numeric)
1918{
1919 // Auto-deduce return type (int)
1920 auto result = zip_map([](auto t) {
1921 return get<0>(t) + get<1>(t);
1922 }, l1, l2);
1923
1924 EXPECT_EQ(result.size(), N);
1925
1926 size_t i = 0;
1927 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
1928 EXPECT_EQ(it.get_curr(), static_cast<int>(2 * i));
1929
1930 // Verify the type is DynList<int>
1931 static_assert(std::is_same_v<decltype(result), DynList<int>>,
1932 "zip_map should return DynList<int>");
1933}
1934
1935TEST_F(CompleteGroup, zip_map_eq_success)
1936{
1937 auto result = zip_map_eq([](auto t) {
1938 return get<0>(t) * get<1>(t);
1939 }, l1, l2);
1940
1941 EXPECT_EQ(result.size(), N);
1942
1943 // 0*0, 1*1, 2*2, 3*3, 4*4
1944 size_t i = 0;
1945 for (auto it = result.get_it(); it.has_curr(); it.next_ne(), ++i)
1946 EXPECT_EQ(it.get_curr(), static_cast<int>(i * i));
1947}
1948
1949TEST_F(InCompleteGroup, zip_map_eq_throws)
1950{
1951 EXPECT_THROW(
1952 zip_map_eq([](auto t) { return get<0>(t); }, l1, l2),
1953 length_error
1954 );
1955}
1956
1957TEST(ZipMapEmpty, empty_containers)
1958{
1959 DynList<int> e1, e2;
1960
1961 auto result = zip_map([](auto t) { return get<0>(t); }, e1, e2);
1962 EXPECT_TRUE(result.is_empty());
1963
1964 // _eq version should not throw on empty (they're equal length)
1965 auto result_eq = zip_map_eq([](auto t) { return get<0>(t); }, e1, e2);
1966 EXPECT_TRUE(result_eq.is_empty());
1967}
1968
1969TEST(ZipFoldlEmpty, empty_containers)
1970{
1971 DynList<int> e1, e2;
1972
1973 auto sum = zip_foldl(100, [](auto acc, auto t) { return acc + get<0>(t); }, e1, e2);
1974 EXPECT_EQ(sum, 100); // Just returns init value
1975
1976 // _eq version should not throw on empty
1977 auto sum_eq = zip_foldl_eq(100, [](auto acc, auto t) { return acc + get<0>(t); }, e1, e2);
1978 EXPECT_EQ(sum_eq, 100);
1979}
1980
1981// ============================================================================
1982// Tests for zip_filter_eq and none_of_tuple
1983// ============================================================================
1984
1985TEST_F(CompleteGroup, zip_filter_eq_success)
1986{
1987 auto result = zip_filter_eq([](auto t) {
1988 return get<0>(t) > 2;
1989 }, l1, l2, l3);
1990
1991 // Should contain elements where first > 2: (3, 3, "3"), (4, 4, "4")
1992 EXPECT_EQ(result.size(), 2u);
1993}
1994
1995TEST_F(InCompleteGroup, zip_filter_eq_throws)
1996{
1997 EXPECT_THROW(
1998 zip_filter_eq([](auto) { return true; }, l1, l2),
1999 length_error
2000 );
2001}
2002
2003TEST(ZipFilterEq, empty_containers)
2004{
2005 DynList<int> e1, e2;
2006 auto result = zip_filter_eq([](auto) { return true; }, e1, e2);
2007 EXPECT_TRUE(result.is_empty());
2008}
2009
2010TEST_F(CompleteGroup, zip_filter_eq_all_match)
2011{
2012 auto result = zip_filter_eq([](auto t) {
2013 return get<0>(t) >= 0;
2014 }, l1, l2);
2015
2016 EXPECT_EQ(result.size(), N);
2017}
2018
2019TEST_F(CompleteGroup, zip_filter_eq_none_match)
2020{
2021 auto result = zip_filter_eq([](auto t) {
2022 return get<0>(t) > 100;
2023 }, l1, l2);
2024
2025 EXPECT_TRUE(result.is_empty());
2026}
2027
2028TEST(NoneOfTuple, all_satisfy)
2029{
2030 auto t = make_tuple(2, 4, 6, 8);
2031 // All are even, so none are odd
2032 EXPECT_TRUE(none_of_tuple([](auto x) { return x % 2 != 0; }, t));
2033}
2034
2035TEST(NoneOfTuple, some_satisfy)
2036{
2037 auto t = make_tuple(2, 3, 6, 8);
2038 // 3 is odd, so NOT none are odd
2039 EXPECT_FALSE(none_of_tuple([](auto x) { return x % 2 != 0; }, t));
2040}
2041
2042TEST(NoneOfTuple, empty_tuple)
2043{
2044 auto t = make_tuple();
2045 // Vacuously true: no elements satisfy any predicate
2046 EXPECT_TRUE(none_of_tuple([](auto) { return true; }, t));
2047}
2048
2049TEST(NoneOfTuple, complement_of_any)
2050{
2051 auto t = make_tuple(1, 2, 3, 4, 5);
2052
2053 auto pred = [](auto x) { return x > 10; };
2054
2055 // none_of should be complement of any_of
2056 EXPECT_EQ(none_of_tuple(pred, t), !any_of_tuple(pred, t));
2057}
2058
2059// Stress test for new functions
2060TEST(StressNewFunctions, large_containers)
2061{
2062 const size_t SIZE = 1000;
2063 DynList<int> l1 = range<int>(0, SIZE - 1);
2064 DynList<int> l2 = range<int>(0, SIZE - 1);
2065
2066 // zip_length
2067 EXPECT_EQ(zip_length(l1, l2), SIZE);
2068
2069 // zip_count - count even numbers
2070 EXPECT_EQ(zip_count([](auto t) { return get<0>(t) % 2 == 0; }, l1, l2), SIZE / 2);
2071
2072 // zip_none - no element > SIZE
2073 EXPECT_TRUE(zip_none([](auto t) { return get<0>(t) >= static_cast<int>(SIZE); }, l1, l2));
2074
2075 // zip_find_first
2076 auto [first, found1] = zip_find_first([](auto t) { return get<0>(t) == 500; }, l1, l2);
2077 EXPECT_TRUE(found1);
2078 EXPECT_EQ(get<0>(first), 500);
2079
2080 // zip_find_last
2081 auto [last, found2] = zip_find_last([](auto t) { return get<0>(t) < 100; }, l1, l2);
2082 EXPECT_TRUE(found2);
2083 EXPECT_EQ(get<0>(last), 99);
2084
2085 // zip_nth
2086 auto [nth, found3] = zip_nth(999, l1, l2);
2087 EXPECT_TRUE(found3);
2088 EXPECT_EQ(get<0>(nth), 999);
2089}
2090
2091// ============================================================================
2092// DynSkipList Specific Tests
2093// ============================================================================
2094
2095TEST(DynSkipListZip, BasicZipOperations)
2096{
2097 DynSkipList<int> skip1{1, 2, 3, 4, 5};
2098 DynSkipList<string> skip2{"a", "b", "c", "d", "e"};
2099 DynList<double> list1{1.1, 2.2, 3.3, 4.4, 5.5};
2100
2101 // Test zip_it with DynSkipList
2102 size_t count = 0;
2103 for (auto it = zip_it(skip1, skip2); it.has_curr(); it.next_ne()) {
2104 auto [i, s] = it.get_curr_ne();
2105 EXPECT_EQ(i, count + 1);
2106 EXPECT_EQ(s, string(1, 'a' + count));
2107 ++count;
2108 }
2109 EXPECT_EQ(count, 5);
2110
2111 // Test zip_traverse with DynSkipList
2112 string result;
2113 zip_traverse([&result](auto t) {
2114 result += to_string(get<0>(t)) + get<1>(t);
2115 return true;
2116 }, skip1, skip2);
2117 EXPECT_EQ(result, "1a2b3c4d5e");
2118
2119 // Test zip_for_each with mixed containers
2120 vector<string> mixed_results;
2121 zip_for_each([&mixed_results](auto t) {
2122 mixed_results.push_back(to_string(get<0>(t)) + ":" + get<1>(t) + ":" + to_string(get<2>(t)));
2123 }, skip1, skip2, list1);
2124 EXPECT_EQ(mixed_results.size(), 5);
2125 EXPECT_TRUE(mixed_results[0].find("1:a:1.1") != string::npos);
2126 EXPECT_TRUE(mixed_results[4].find("5:e:5.5") != string::npos);
2127
2128 // Test zip_all with DynSkipList
2129 bool all_positive = zip_all([](auto t) { return get<0>(t) > 0; }, skip1, skip2);
2130 EXPECT_TRUE(all_positive);
2131
2132 // Test zip_exists with DynSkipList
2133 bool has_three = zip_exists([](auto t) { return get<0>(t) == 3; }, skip1, skip2);
2134 EXPECT_TRUE(has_three);
2135
2136 // Test zip_map with DynSkipList
2137 auto mapped = zip_map([](auto t) { return get<0>(t) * 10; }, skip1, skip2);
2138 EXPECT_EQ(mapped.size(), 5);
2139 EXPECT_EQ(mapped[0], 10);
2140 EXPECT_EQ(mapped[4], 50);
2141}
2142
2143// The zip functions call their operation once per tuple, so they must call
2144// it as an lvalue. They called std::forward<Op>(op)(...) at each step: a
2145// temporary was called through an rvalue each time, and one whose rvalue
2146// call consumes its state, as a one-shot task does, lost it after the
2147// first call. The operation counts the calls through each kind of value
2148namespace
2149{
2150 struct Counting_Pred
2151 {
2152 int *lvalue_calls = nullptr;
2153 int *rvalue_calls = nullptr;
2154 bool operator()(const auto &) & { ++*lvalue_calls; return true; }
2155 bool operator()(const auto &) && { ++*rvalue_calls; return true; }
2156 };
2157}
2158
2159TEST(ZipOperations, TemporaryCallableIsCalledAsLvalue)
2160{
2161 DynList<int> l = {1, 2, 3};
2162 int lv = 0, rv = 0;
2163 auto pred = [&lv, &rv]
2164 {
2165 lv = rv = 0;
2166 return Counting_Pred{&lv, &rv};
2167 };
2168
2169 EXPECT_TRUE(zip_all(pred(), l, l));
2170 EXPECT_EQ(lv, 3);
2171 EXPECT_EQ(rv, 0);
2172
2173 EXPECT_TRUE(zip_traverse(pred(), l, l));
2174 EXPECT_EQ(lv, 3);
2175 EXPECT_EQ(rv, 0);
2176
2177 EXPECT_EQ(zip_count(pred(), l, l), 3u);
2178 EXPECT_EQ(lv, 3);
2179 EXPECT_EQ(rv, 0);
2180
2181 EXPECT_FALSE(zip_none(pred(), l, l));
2182 EXPECT_EQ(lv, 1);
2183 EXPECT_EQ(rv, 0);
2184}
String manipulation utilities.
Zip iterators and functional operations for multiple containers.
TEST_F(EmptyGroup, empty)
Definition ah-zip.cc:77
Functional programming utilities for Aleph-w containers.
Simple dynamic array with automatic resizing and functional operations.
Definition tpl_array.H:141
bool contains(const Key &key) const noexcept
Return true if the key exists in the table.
Doubly-linked list (defined in tpl_dynList.H).
Definition htlist.H:1231
size_t size() const noexcept
Return the number of items of the list, in constant time.
Definition htlist.H:1264
Dynamic set backed by balanced binary search trees with automatic memory management.
size_t height() const
Calculates and returns the height of the binary search tree.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
bool contains(const Key &key) const
Checks if a key exists in the set.
Dynamic ordered set implemented with a Skip List.
Number Theoretic Transform over Z / MOD Z.
Definition ntt.H:115
Minimal std::expected-style result type for C++20.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps(Operation &op) const
Definition ah-dry.H:1829
Type & nth(const size_t n)
Return the n-th item of the container.
Definition ah-dry.H:774
Iterator that traverses multiple Aleph containers in lockstep.
#define TEST(name)
#define N
Definition fib.C:294
Freq_Node * pred
Predecessor node in level-order traversal.
Main namespace for Aleph-w library functions.
ZipIterator< Cs... > zip_it(const Cs &...cs)
Alias for get_zip_it.
Definition ah-zip.H:359
void zip_for_each_eq(Op &&op, const Cs &...cs)
Apply op to every zipped tuple; throw if containers differ in length.
Definition ah-zip.H:485
bool zip_traverse_eq(Op &&op, const Cs &...cs)
Traverse zipped containers while op returns true; verify equal lengths.
Definition ah-zip.H:432
void zip_for_each_indexed_eq(Op &&op, const Cs &...cs)
Apply op to each zipped tuple with index; throw if lengths differ.
Definition ah-zip.H:1727
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
auto zip_drop_while(Pred &&pred, const Cs &...cs)
Skip tuples while predicate pred returns true, then return the rest.
Definition ah-zip.H:1813
auto t_enum_zip_eq(const Cs &...cs)
Materialize enumerated zipped tuples; throw if containers differ in length.
Definition ah-zip.H:1461
void zip_for_each(Op &&op, const Cs &...cs)
Apply op to every zipped tuple.
Definition ah-zip.H:471
EnumZipIterator< Cs... > enum_zip_it_pos(size_t pos, const Cs &...cs)
Alias for get_enum_zip_it_pos.
Definition ah-zip.H:1428
ZipIterator< Cs... > zip_it_pos(size_t pos, const Cs &...cs)
Alias for get_zip_it_pos.
Definition ah-zip.H:366
bool zip_forall_short(Op &&op, const Cs &...cs)
Alias for zip_all_short.
Definition ah-zip.H:550
auto std_zip(const C1 &c1, const C2 &c2)
Build a vector of pairs from two STL containers.
Definition ah-zip.H:1587
bool all_of_tuple(Pred &&pred, const Tuple &t)
Return true if all tuple elements satisfy pred.
Definition ah-zip.H:1982
auto transform_tuple(Op &&op, Tuple &&t)
Transform each element of a tuple, returning a new tuple.
Definition ah-zip.H:1951
auto zip_transform_eq(Op &&op, const Cs &...cs)
Transform zipped tuples; throw if containers differ in length.
Definition ah-zip.H:1689
bool equal_length(const Cs &...cs)
Return true if all containers have the same length.
Definition ah-zip.H:378
T zip_foldl(const T &init, Op op, const Cs &...cs)
Left fold (reduce) over zipped tuples.
Definition ah-zip.H:806
bool zip_all_short(Op &&op, const Cs &...cs)
Return true if op returns true for all tuples (without length check).
Definition ah-zip.H:526
void for_each_in_tuple(Op &&op, Tuple &&t)
Apply op to each element of a tuple.
Definition ah-zip.H:1911
auto std_zip_n(const Cs &...cs)
Build a vector of tuples from 2 or more STL containers (variadic).
Definition ah-zip.H:1650
size_t zip_length(const Cs &...cs)
Count all tuples (minimum length of containers).
Definition ah-zip.H:623
auto zip_filter(Op op, const Cs &...cs)
Filter zipped tuples by predicate op.
Definition ah-zip.H:959
T zip_foldl_eq(const T &init, Op op, const Cs &...cs)
Left fold over zipped tuples; throw if containers differ in length.
Definition ah-zip.H:826
auto t_zip(const Cs &...cs)
Materialize zipped tuples into a DynList.
Definition ah-zip.H:1174
bool zip_any(Op &&op, const Cs &...cs)
Alias for zip_exists.
Definition ah-zip.H:579
auto zip_lists(const C &c, const Lists &...lists)
Take several container of same type and some length and builds a list of lists.
Definition ah-zip.H:1515
bool zip_forall(Op &&op, const Cs &...cs)
Alias for zip_all.
Definition ah-zip.H:540
bool any_of_tuple(Pred &&pred, const Tuple &t)
Return true if any tuple element satisfies pred.
Definition ah-zip.H:2012
size_t zip_count(Op &&op, const Cs &...cs)
Count tuples that satisfy predicate op.
Definition ah-zip.H:607
bool zip_traverse(Op &&op, const Cs &...cs)
Traverse zipped containers while op returns true.
Definition ah-zip.H:415
Itor find(const Itor &beg, const Itor &end, const T &value)
Find the first element equal to a value.
Definition ahAlgo.H:230
auto zip_find_first(Op &&op, const Cs &...cs)
Return the first tuple that satisfies predicate op.
Definition ah-zip.H:641
and
Check uniqueness with explicit hash + equality functors.
bool zip_all(Op &&op, const Cs &...cs)
Return true if op returns true for all tuples and containers have equal length.
Definition ah-zip.H:505
auto t_zip_eq(const Cs &...cs)
Materialize zipped tuples; throw if containers differ in length.
Definition ah-zip.H:1193
bool none_of_tuple(Pred &&pred, const Tuple &t)
Return true if no tuple element satisfies pred.
Definition ah-zip.H:2042
bool zip_none(Op &&op, const Cs &...cs)
Return true if op returns false for all tuples.
Definition ah-zip.H:594
auto tzip_std(const Cs &...cs)
Build a vector of tuples from 2 or more STL containers (variadic).
Definition ah-zip.H:1615
auto t_enum_zip(const Cs &...cs)
Materialize enumerated zipped tuples into a DynList.
Definition ah-zip.H:1442
auto zip_first(const Cs &...cs)
Return the first tuple from zipped containers.
Definition ah-zip.H:710
EnumZipIterator< Cs... > enum_zip_it(const Cs &...cs)
Alias for get_enum_zip_it.
Definition ah-zip.H:1421
auto zip_find_last(Op &&op, const Cs &...cs)
Return the last tuple that satisfies predicate op.
Definition ah-zip.H:662
auto t_unzip(const DynList< std::tuple< Ts... > > &tuples)
Unzip a list of tuples into a tuple of lists.
Definition ah-zip.H:1491
auto zip_map(Op &&op, const Cs &...cs)
Map op over zipped tuples with auto-deduced return type.
Definition ah-zip.H:898
auto zip_partition(Op op, const Cs &...cs)
Partition zipped tuples by predicate op.
Definition ah-zip.H:1124
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
Definition ah-date.H:140
size_t zip_find_index(Op op, const Cs &...cs)
Find the first index where op returns true.
Definition ah-zip.H:1077
auto zip_take_while(Pred &&pred, const Cs &...cs)
Take tuples while predicate pred returns true.
Definition ah-zip.H:1790
void zip_for_each_indexed(Op &&op, const Cs &...cs)
Apply op to each zipped tuple along with its index.
Definition ah-zip.H:1712
bool zip_exists(Op &&op, const Cs &...cs)
Return true if op returns true for at least one tuple.
Definition ah-zip.H:565
auto zip_drop(const size_t n, const Cs &...cs)
Skip n tuples and return the rest.
Definition ah-zip.H:1765
auto zip_filter_eq(Op op, const Cs &...cs)
Filter zipped tuples by predicate op; throw if containers differ in length.
Definition ah-zip.H:1000
auto zip_nth(size_t n, const Cs &...cs)
Return the n-th tuple from zipped containers.
Definition ah-zip.H:689
auto zip_lists_eq(const C &c, const Lists &...lists)
Like zip_lists but throws if containers differ in length.
Definition ah-zip.H:1534
bool zip_cmp(Cmp cmp, const Cs &...cs)
Return true if cmp(t) is true for each built tuple t.
Definition ah-zip.H:1054
auto get_pair_it(C1 &c1, C2 &c2)
Create a Pair_Iterator for two containers.
auto zip_map_eq(Op &&op, const Cs &...cs)
Map op over zipped tuples with auto-deduced return type; throw if lengths differ.
Definition ah-zip.H:919
auto zip_transform(Op &&op, const Cs &...cs)
Transform zipped tuples using op and return results in a vector.
Definition ah-zip.H:1667
auto zip_take(size_t n, const Cs &...cs)
Take at most n tuples from the zipped containers.
Definition ah-zip.H:1746
void next_ne() noexcept(noexcept(std::declval< Aleph::const_iterator_t< HeadC > & >().next_ne()) and noexcept(std::declval< ZipIterator< TailC... > & >().next_ne()))
Advance all underlying iterators (unchecked variant).
Definition ah-zip.H:252
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Definition ahAlgo.H:127
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
STL namespace.
Hash-based dynamic set (defined in tpl_dynSetHash.H).
DynSkipList< int > l4
Definition ah-zip.cc:66
DynList< int > l1
Definition ah-zip.cc:62
DynSetTree< int > l2
Definition ah-zip.cc:63
DynArray< string > l3
Definition ah-zip.cc:64
DynSkipList< int > l4
Definition ah-zip.cc:56
DynSetTree< int > l2
Definition ah-zip.cc:54
DynArray< string > l3
Definition ah-zip.cc:55
DynList< int > l1
Definition ah-zip.cc:53
Aleph::DynList< T > keys() const
See items().
Definition ah-dry.H:2916
DynSkipList< int > l4
Definition ah-zip.cc:74
DynArray< string > l3
Definition ah-zip.cc:73
DynSetTree< int > l2
Definition ah-zip.cc:72
DynList< int > l1
Definition ah-zip.cc:71
DynList< char > l3
DynList< int > l1
DynList< int > l2
DynSetTree< char > l5
Dynamic array container with automatic resizing.
Lazy and scalable dynamic array implementation.
Dynamic set implementations based on hash tables.
Dynamic set implementations based on balanced binary search trees.
DynList< int > l