37# include <gtest/gtest.h>
54 EXPECT_EQ(
range(0, 10), build_dynlist<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
55 EXPECT_EQ(
range(0, 10, 2), build_dynlist<int>(0, 2, 4, 6, 8, 10));
56 EXPECT_EQ(
nrange(2, 5, 3), build_dynlist<int>(2, 3, 5));
58 EXPECT_EQ(
range(5), build_dynlist<int>(0, 1, 2, 3, 4));
63 EXPECT_EQ(
rep(5, 0), build_dynlist<int>(0, 0, 0, 0, 0));
64 EXPECT_EQ(
rep(3), build_dynlist<int>(0, 0, 0));
69 auto sq = [] (
int x) {
return x * x; };
70 auto r = set_range<int, DynList>(0, 4, 1, sq);
71 EXPECT_EQ(
r, build_dynlist<int>(0, 1, 4, 9, 16));
73 auto r2 = set_range<int, DynList>(0, 6, 2, sq);
74 EXPECT_EQ(r2, build_dynlist<int>(0, 4, 16, 36));
90 static constexpr size_t N = 10;
94 tbl = range<size_t>(0,
N - 1);
103 for (
auto it =
l.
get_it(); it.has_curr(); it.next_ne(), ++i)
104 EXPECT_EQ(*it.get_curr_ne(), i);
106 EXPECT_TRUE(
zip_all([] (
auto t) {
return *get<0>(t) == get<1>(t); },
l,
tbl));
111 EXPECT_EQ(
sublist(
tbl, 2), build_dynlist<size_t>(0, 2, 4, 6, 8));
112 EXPECT_EQ(
sublist(
tbl, 1, 3), build_dynlist<size_t>(1, 4, 7));
129 EXPECT_TRUE(
all(
tbl, [&i] (
auto &
k) {
return k == i++; }));
131 EXPECT_TRUE(
exists(
tbl, [] (
auto & i) {
return i == 3; }));
132 EXPECT_FALSE(
exists(
tbl, [] (
auto & i) {
return i ==
N; }));
134 auto lfilt =
filter(
tbl, [] (
auto & i) {
return i <= 3; });
135 EXPECT_EQ(lfilt, build_dynlist<size_t>(0, 1, 2, 3));
137 auto lp = maps<string>(
tbl, [] (
const auto & i) {
return to_string(i); });
138 EXPECT_EQ(lp, build_dynlist<string>
139 (
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"));
141 auto lf = foldl<size_t>(
tbl, 0, [] (
auto & a,
auto & i) {
return a + i; });
142 EXPECT_EQ(lf,
N*(
N - 1)/2);
149 ( build_dynlist<size_t>(0, 1, 2, 3, 4, 5, 6),
150 build_dynlist<size_t>(1, 2, 3, 4, 5, 6, 7),
151 build_dynlist<size_t>(2, 3, 4, 5, 6, 7, 8),
152 build_dynlist<size_t>(3, 4, 5, 6, 7, 8, 9) ));
158 EXPECT_TRUE(
l.
all([] (
auto & p) { return p.first == p.second; }));
165 for (
auto it = idx.get_it(); it.has_curr(); it.next_ne(), ++i)
167 auto & p = it.get_curr();
168 EXPECT_EQ(p.first, i);
169 EXPECT_EQ(p.second, i);
174 for (
auto it = tidx.get_it(); it.has_curr(); it.next_ne(), ++i)
176 auto & t = it.get_curr();
177 EXPECT_EQ(get<0>(t), i);
178 EXPECT_EQ(get<1>(t), i);
186 EXPECT_EQ(rev, build_dynlist<size_t>(9, 8, 7, 6, 5, 4, 3, 2, 1, 0));
191 auto p =
partition(
tbl, [] (
const size_t & i) {
return i < 5; });
192 EXPECT_EQ(p.first, build_dynlist<size_t>(0, 1, 2, 3, 4));
193 EXPECT_EQ(p.second, build_dynlist<size_t>(5, 6, 7, 8, 9));
214 constexpr size_t N = 20;
220 EXPECT_TRUE(
eq(
l1, s1));
227 EXPECT_TRUE(get<0>(d));
228 EXPECT_EQ(get<1>(d),
N);
232 EXPECT_FALSE(
eq(
l1, s1));
236 EXPECT_FALSE(get<0>(d));
237 EXPECT_EQ(get<1>(d),
N - 1);
238 EXPECT_EQ(get<2>(d),
N - 2);
239 EXPECT_EQ(get<3>(d),
N - 1);
246 EXPECT_TRUE(z.all([] (
auto & p) { return p.first == p.second; }));
249 EXPECT_TRUE(
zip_all([] (
auto p) {
return get<0>(p) == get<1>(p); },
254 EXPECT_TRUE(z.all([] (
auto & p) { return get<0>(p) == get<1>(p); }));
257 EXPECT_TRUE(
zip_all([] (
auto p) {
return get<0>(p) == get<1>(p); },
258 get<0>(p), get<1>(p)));
262 EXPECT_TRUE(z.all([] (
auto & p) { return p.first == p.second; }));
267 EXPECT_TRUE(
zip_all([] (
auto p) {
return get<0>(p) == get<1>(p); },
272 EXPECT_TRUE(z.all([] (
auto & p) { return get<0>(p) == get<1>(p); }));
277 EXPECT_TRUE(
zip_all([] (
auto p) {
return get<0>(p) == get<1>(p); },
278 get<0>(p), get<1>(p)));
284 DynList<int> l = build_dynlist<int>(1, 1, 2, 2, 2, 4, 4, 0, 0, 1);
286 EXPECT_EQ(result.second, 5);
287 auto & groups = result.first;
289 auto it = groups.get_it();
290 EXPECT_EQ(it.get_curr(), build_dynlist<int>(1, 1)); it.next();
291 EXPECT_EQ(it.get_curr(), build_dynlist<int>(2, 2, 2)); it.next();
292 EXPECT_EQ(it.get_curr(), build_dynlist<int>(4, 4)); it.next();
293 EXPECT_EQ(it.get_curr(), build_dynlist<int>(0, 0)); it.next();
294 EXPECT_EQ(it.get_curr(), build_dynlist<int>(1));
299 EXPECT_EQ(empty_result.second, 0);
300 EXPECT_TRUE(empty_result.first.is_empty());
305 DynList<int> l = build_dynlist<int>(1, 1, 2, 2, 2, 4, 4, 0, 0, 1);
307 EXPECT_EQ(result.second, 5);
308 EXPECT_EQ(result.first, build_dynlist<int>(1, 2, 4, 0, 1));
313 EXPECT_EQ(empty_result.second, 0);
314 EXPECT_TRUE(empty_result.first.is_empty());
317TEST(pair_iterator_test, pair_iterator)
324 while (pit.has_curr())
326 auto p = pit.get_curr();
327 EXPECT_EQ(p.first, i);
328 EXPECT_EQ(p.second, i);
333 EXPECT_TRUE(pit.was_traversed());
337 auto p = pit2.get_curr();
338 EXPECT_EQ(p.first, 2);
339 EXPECT_EQ(p.second, 2);
342TEST(container_ops, insert_append_remove)
347 EXPECT_EQ(c, build_dynlist<int>(1, 2, 3));
352 EXPECT_EQ(s.
size(), 5);
356 EXPECT_EQ(s.
size(), 2);
362 auto dst = assign_container<DynList<int>,
DynList<int>>(src);
369 ll.
append(build_dynlist<int>(1, 2, 3));
370 ll.
append(build_dynlist<int>(4, 5));
371 ll.
append(build_dynlist<int>(6, 7, 8, 9));
374 EXPECT_EQ(flat, build_dynlist<int>(1, 2, 3, 4, 5, 6, 7, 8, 9));
390 EXPECT_FALSE(
is_equal(5, 1, 2, 3, 4));
395 EXPECT_TRUE(
is_equal(5, 3, 5.0, 7));
409 EXPECT_THROW(n.
get_item(), std::logic_error);
412 EXPECT_THROW(cn.
get_item(), std::logic_error);
421 auto r = nrange<double, DynList>(0.0, 1.0, 11);
422 EXPECT_EQ(
r.size(), 11u);
423 EXPECT_DOUBLE_EQ(
r.get_first(), 0.0);
424 EXPECT_DOUBLE_EQ(
r.get_last(), 1.0);
425 EXPECT_DOUBLE_EQ(
r.nth(5), 0.5);
428 auto r1 = nrange<int, DynList>(10, 20, 1);
429 ASSERT_EQ(r1.size(), 1u);
430 EXPECT_EQ(r1.get_first(), 10);
433 EXPECT_THROW(
nrange(0, 10, 0), std::domain_error);
436TEST(flatten_test, flatten_deep)
443 EXPECT_EQ(flat, build_dynlist<int>(1, 2, 3, 4, 5, 6));
448 EXPECT_EQ(flat4, build_dynlist<int>(1, 2, 3, 4, 5, 6));
467 EXPECT_TRUE(
none(
l, [] (
int x) {
return x > 10; }));
468 EXPECT_FALSE(
none(
l, [] (
int x) {
return x == 3; }));
471 EXPECT_TRUE(
none(empty, [] (
int) {
return true; }));
474TEST(find_ptr_test, find_ptr_basic)
478 auto * p =
find_ptr(
l, [] (
int x) {
return x == 3; });
479 ASSERT_NE(p,
nullptr);
484 EXPECT_EQ(
l.
nth(2), 30);
486 auto * not_found =
find_ptr(
l, [] (
int x) {
return x == 100; });
487 EXPECT_EQ(not_found,
nullptr);
491 const int * cp =
find_ptr(cl, [] (
int x) {
return x == 20; });
492 ASSERT_NE(cp,
nullptr);
501 auto result = foldr<int>(
l, 0, [] (
int a,
int b) {
return a - b; });
502 EXPECT_EQ(result, -2);
505 auto result_l = foldl<int>(
l, 0, [] (
int a,
int b) {
return a - b; });
506 EXPECT_EQ(result_l, -10);
509TEST(sum_product_test, sum_product_basic)
512 EXPECT_EQ(
sum(
l), 15);
513 EXPECT_EQ(
sum(
l, 10), 25);
519 EXPECT_EQ(
sum(empty), 0);
523 EXPECT_DOUBLE_EQ(
sum(ld), 7.0);
532 EXPECT_EQ(c, build_dynlist<int>(1, 2, 3, 4, 5, 6));
539TEST(take_while_test, take_while_basic)
543 auto result =
take_while(
l, [] (
int x) {
return x < 5; });
544 EXPECT_EQ(result, build_dynlist<int>(1, 2, 3));
551 auto none_result =
take_while(
l, [] (
int x) {
return x > 100; });
552 EXPECT_TRUE(none_result.is_empty());
555TEST(drop_while_test, drop_while_basic)
559 auto result =
drop_while(
l, [] (
int x) {
return x < 5; });
560 EXPECT_EQ(result, build_dynlist<int>(10, 5, 6));
563 auto all_dropped =
drop_while(
l, [] (
int) {
return true; });
564 EXPECT_TRUE(all_dropped.is_empty());
567 auto none_dropped =
drop_while(
l, [] (
int x) {
return x > 100; });
568 EXPECT_EQ(none_dropped,
l);
571TEST(flat_map_test, flat_map_basic)
577 return build_dynlist<int>(x, x);
579 EXPECT_EQ(result, build_dynlist<int>(1, 1, 2, 2, 3, 3));
585 EXPECT_EQ(ranges, build_dynlist<int>(0, 0, 1, 0, 1, 2));
592 auto sums = scanl<int>(
l, 0, [] (
int a,
int b) {
return a + b; });
593 EXPECT_EQ(sums, build_dynlist<int>(0, 1, 3, 6, 10));
596 EXPECT_EQ(sums2, build_dynlist<int>(0, 1, 3, 6, 10));
599 auto empty_scan = scanl<int>(empty, 100, [] (
int a,
int b) {
return a + b; });
600 EXPECT_EQ(empty_scan, build_dynlist<int>(100));
603TEST(min_max_test, min_max_basic)
608 ASSERT_NE(min_p,
nullptr);
609 EXPECT_EQ(*min_p, 1);
612 ASSERT_NE(max_p,
nullptr);
613 EXPECT_EQ(*max_p, 9);
616 ASSERT_NE(minp,
nullptr);
617 ASSERT_NE(maxp,
nullptr);
623 EXPECT_EQ(
min_ptr(empty),
nullptr);
624 EXPECT_EQ(
max_ptr(empty),
nullptr);
626 EXPECT_EQ(emp_min,
nullptr);
627 EXPECT_EQ(emp_max,
nullptr);
632 EXPECT_EQ(*s_min, 42);
633 EXPECT_EQ(*s_max, 42);
636 DynList<int> abs_list = build_dynlist<int>(-10, 5, -20, 3);
637 auto * max_abs =
max_ptr(abs_list,
638 [] (
const int a,
const int b) {
return std::abs(a) < std::abs(b); });
639 EXPECT_EQ(*max_abs, -20);
642TEST(count_if_test, count_if_basic)
644 DynList<int> l = build_dynlist<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
646 EXPECT_EQ(
count_if(
l, [] (
int x) {
return x % 2 == 0; }), 5);
647 EXPECT_EQ(
count_if(
l, [] (
int x) {
return x > 5; }), 5);
648 EXPECT_EQ(
count_if(
l, [] (
int x) {
return x > 100; }), 0);
651 EXPECT_EQ(
count_if(empty, [] (
int) {
return true; }), 0);
654TEST(contains_test, contains_basic)
668TEST(enumerate_tuple_test, enumerate_tuple_basic)
673 EXPECT_EQ(result.size(), 3);
675 auto it = result.get_it();
676 EXPECT_EQ(get<0>(it.get_curr()), 0);
677 EXPECT_EQ(get<1>(it.get_curr()),
"a");
679 EXPECT_EQ(get<0>(it.get_curr()), 1);
680 EXPECT_EQ(get<1>(it.get_curr()),
"b");
682 EXPECT_EQ(get<0>(it.get_curr()), 2);
683 EXPECT_EQ(get<1>(it.get_curr()),
"c");
692TEST(zip_longest_test, basic_different_lengths)
698 EXPECT_EQ(result.size(), 5);
700 auto it = result.get_it();
701 EXPECT_EQ(it.get_curr(), make_pair(1, 10)); it.next();
702 EXPECT_EQ(it.get_curr(), make_pair(2, 20)); it.next();
703 EXPECT_EQ(it.get_curr(), make_pair(3, 30)); it.next();
704 EXPECT_EQ(it.get_curr(), make_pair(4, -1)); it.next();
705 EXPECT_EQ(it.get_curr(), make_pair(5, -1));
708TEST(zip_longest_test, second_longer)
714 EXPECT_EQ(result.size(), 4);
716 auto it = result.get_it();
717 EXPECT_EQ(it.get_curr(), make_pair(1, 10)); it.next();
718 EXPECT_EQ(it.get_curr(), make_pair(2, 20)); it.next();
719 EXPECT_EQ(it.get_curr(), make_pair(0, 30)); it.next();
720 EXPECT_EQ(it.get_curr(), make_pair(0, 40));
723TEST(zip_longest_test, equal_lengths)
729 EXPECT_EQ(result.size(), 3);
731 EXPECT_TRUE(result.all([] (
auto & p) {
732 return p.first + 3 == p.second;
736TEST(zip_longest_test, empty_containers)
742 EXPECT_TRUE(r1.is_empty());
745 EXPECT_EQ(r2.size(), 3);
746 EXPECT_TRUE(r2.all([] (
auto & p) { return p.second == -1; }));
749 EXPECT_EQ(r3.size(), 3);
750 EXPECT_TRUE(r3.all([] (
auto & p) { return p.first == -1; }));
755TEST(tzip_longest_test, basic_different_lengths)
761 EXPECT_EQ(result.size(), 3);
763 auto it = result.get_it();
764 EXPECT_EQ(get<0>(it.get_curr()), 1);
765 EXPECT_EQ(get<1>(it.get_curr()),
"a");
767 EXPECT_EQ(get<0>(it.get_curr()), 2);
768 EXPECT_EQ(get<1>(it.get_curr()),
"b");
770 EXPECT_EQ(get<0>(it.get_curr()), 3);
771 EXPECT_EQ(get<1>(it.get_curr()),
"X");
776TEST(zip_longest_opt_test, basic_different_lengths)
782 EXPECT_EQ(result.size(), 4);
784 auto it = result.get_it();
785 auto p1 = it.get_curr();
786 EXPECT_TRUE(p1.first.has_value());
787 EXPECT_TRUE(p1.second.has_value());
788 EXPECT_EQ(p1.first.value(), 1);
789 EXPECT_EQ(p1.second.value(), 10);
791 it.next(); it.next(); it.next();
792 auto p4 = it.get_curr();
793 EXPECT_TRUE(p4.first.has_value());
794 EXPECT_FALSE(p4.second.has_value());
795 EXPECT_EQ(p4.first.value(), 4);
800TEST(group_by_test, basic_grouping)
805 auto result =
group_by(
l, [] (
int x) {
return x; });
806 EXPECT_EQ(result.size(), 4);
808 auto it = result.get_it();
810 EXPECT_EQ(it.get_curr().first, 1);
811 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(1, 1));
813 EXPECT_EQ(it.get_curr().first, 2);
814 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(2, 2, 2));
816 EXPECT_EQ(it.get_curr().first, 3);
817 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(3));
819 EXPECT_EQ(it.get_curr().first, 1);
820 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(1, 1));
823TEST(group_by_test, group_by_parity)
828 auto result =
group_by(
l, [] (
int x) {
return x % 2; });
829 EXPECT_EQ(result.size(), 3);
831 auto it = result.get_it();
832 EXPECT_EQ(it.get_curr().first, 1);
833 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(1, 3, 5));
835 EXPECT_EQ(it.get_curr().first, 0);
836 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(2, 4, 6));
838 EXPECT_EQ(it.get_curr().first, 1);
839 EXPECT_EQ(it.get_curr().second, build_dynlist<int>(7, 9));
842TEST(group_by_test, empty_container)
845 auto result =
group_by(empty, [] (
int x) {
return x; });
846 EXPECT_TRUE(result.is_empty());
849TEST(group_by_test, single_element)
852 auto result =
group_by(single, [] (
int x) {
return x; });
853 EXPECT_EQ(result.size(), 1);
854 EXPECT_EQ(result.get_first().first, 42);
855 EXPECT_EQ(result.get_first().second, build_dynlist<int>(42));
860TEST(group_by_reduce_test, sum_groups)
865 [] (
int x) {
return x; },
870 EXPECT_EQ(result.size(), 3);
872 auto it = result.get_it();
874 EXPECT_EQ(it.get_curr().first, 1);
875 EXPECT_EQ(it.get_curr().second, 2);
878 EXPECT_EQ(it.get_curr().first, 2);
879 EXPECT_EQ(it.get_curr().second, 6);
882 EXPECT_EQ(it.get_curr().first, 3);
883 EXPECT_EQ(it.get_curr().second, 3);
892 auto result = maps<int>(
l, [] (
int x) {
return x * x; });
893 EXPECT_EQ(result, build_dynlist<int>(1, 4, 9, 16, 25));
896TEST(maps_test, type_conversion)
900 auto result = maps<string>(
l, [] (
int x) {
return to_string(x); });
901 EXPECT_EQ(result, build_dynlist<string>(
"1",
"2",
"3"));
904TEST(filter_map_test, conditional_map)
909 auto filtered =
filter(
l, [] (
int x) {
return x % 2 == 0; });
910 auto result = maps<int>(filtered, [] (
int x) {
return x * x; });
912 EXPECT_EQ(result, build_dynlist<int>(4, 16, 36));
915TEST(filter_map_test, no_matches)
919 auto filtered =
filter(
l, [] (
int x) {
return x % 2 == 0; });
920 auto result = maps<int>(filtered, [] (
int x) {
return x * 2; });
922 EXPECT_TRUE(result.is_empty());
932 auto left =
l.
take(3);
933 auto right =
l.
drop(3);
935 EXPECT_EQ(left, build_dynlist<int>(1, 2, 3));
936 EXPECT_EQ(right, build_dynlist<int>(4, 5, 6));
941TEST(take_drop_test, take_basic)
945 EXPECT_EQ(
l.
take(3), build_dynlist<int>(1, 2, 3));
950TEST(take_drop_test, drop_basic)
954 EXPECT_EQ(
l.
drop(2), build_dynlist<int>(3, 4, 5));
959TEST(take_drop_test, take_drop_range)
961 DynList<int> l = build_dynlist<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
964 auto result =
l.
take(3, 7);
965 EXPECT_EQ(result, build_dynlist<int>(3, 4, 5, 6, 7));
970TEST(to_dynlist_test, from_tree)
973 for (
int i = 0; i < 5; ++i)
977 EXPECT_EQ(list.size(), 5);
978 EXPECT_EQ(list, build_dynlist<int>(0, 1, 2, 3, 4));
981TEST(to_dynlist_test, from_array)
984 for (
int i = 0; i < 5; ++i)
988 EXPECT_EQ(list.size(), 5);
989 EXPECT_EQ(list, build_dynlist<int>(0, 2, 4, 6, 8));
994TEST(traverse_filter_test, count_evens)
996 DynList<int> l = build_dynlist<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1000 if (x % 2 == 0) ++
count;
1004 EXPECT_EQ(
count, 5);
1009TEST(functional_stress_test, large_container)
1011 constexpr size_t N = 10000;
1015 auto sum = foldl<size_t>(
l, 0, [] (
size_t a,
size_t b) {
return a + b; });
1016 EXPECT_EQ(
sum,
N * (
N - 1) / 2);
1019 auto evens =
filter(
l, [] (
size_t x) {
return x % 2 == 0; });
1020 EXPECT_EQ(evens.size(),
N / 2);
1023 auto doubled = maps<size_t>(
l, [] (
size_t x) {
return x * 2; });
1024 EXPECT_EQ(doubled.size(),
N);
1025 EXPECT_EQ(doubled.get_first(), 0);
1026 EXPECT_EQ(doubled.get_last(), (
N - 1) * 2);
1029TEST(functional_stress_test, chained_operations)
1034 auto result =
filter(
l, [] (
int x) {
return x % 2 == 0; });
1035 auto squared = maps<int>(result, [] (
int x) {
return x * x; });
1036 auto first5 = squared.take(5);
1037 auto total =
sum(first5);
1039 EXPECT_EQ(total, 0 + 4 + 16 + 36 + 64);
1042TEST(functional_edge_test, empty_container_operations)
1047 EXPECT_TRUE(
filter(empty, [] (
int) {
return true; }).is_empty());
1048 EXPECT_TRUE(maps<int>(empty, [] (
int x) {
return x; }).is_empty());
1049 EXPECT_EQ(foldl<int>(empty, 42, [] (
int a,
int b) {
return a + b; }), 42);
1050 EXPECT_TRUE(
all(empty, [] (
int) {
return false; }));
1051 EXPECT_FALSE(
exists(empty, [] (
int) {
return true; }));
1052 EXPECT_TRUE(
none(empty, [] (
int) {
return true; }));
1053 EXPECT_EQ(
sum(empty), 0);
1055 EXPECT_TRUE(
reverse(empty).is_empty());
1058TEST(functional_edge_test, single_element)
1062 EXPECT_EQ(
filter(single, [] (
int x) {
return x > 0; }).
size(), 1);
1063 EXPECT_EQ(maps<int>(single, [] (
int x) {
return x * 2; }).get_first(), 84);
1064 EXPECT_EQ(
sum(single), 42);
1065 EXPECT_EQ(
product(single), 42);
1066 EXPECT_EQ(
reverse(single).get_first(), 42);
1067 EXPECT_EQ(*
min_ptr(single), 42);
1068 EXPECT_EQ(*
max_ptr(single), 42);
1084TEST(functional_complex_type_test, struct_operations)
1087 people.
append({
"Alice", 30});
1088 people.
append({
"Bob", 25});
1089 people.
append({
"Charlie", 35});
1090 people.
append({
"Diana", 28});
1093 auto over28 =
filter(people, [] (
const Person & p) {
return p.
age > 28; });
1094 EXPECT_EQ(over28.size(), 2);
1097 auto names = maps<string>(people, [] (
const Person & p) {
return p.
name; });
1098 EXPECT_EQ(names, build_dynlist<string>(
"Alice",
"Bob",
"Charlie",
"Diana"));
1104 ASSERT_NE(oldest,
nullptr);
1105 EXPECT_EQ(oldest->name,
"Charlie");
1108 auto total_age = foldl<int>(people, 0, [] (
int acc,
const Person & p) {
1111 EXPECT_EQ(total_age, 30 + 25 + 35 + 28);
1116TEST(functional_composition_test, nested_maps)
1121 auto result = maps<int>(maps<int>(
l, [] (
int x) {
return x + 1; }),
1122 [] (
int x) {
return x * x; });
1123 EXPECT_EQ(result, build_dynlist<int>(4, 9, 16));
1126TEST(functional_composition_test, filter_then_map)
1130 auto result = maps<string>(
1131 filter(
l, [] (
int x) {
return x % 3 == 0; }),
1132 [] (
int x) {
return "val" +
to_string(x); }
1135 EXPECT_EQ(result, build_dynlist<string>(
"val0",
"val3",
"val6",
"val9"));
1140TEST(quantifier_test, all_comprehensive)
1144 EXPECT_TRUE(
all(
l, [] (
int x) {
return x % 2 == 0; }));
1145 EXPECT_TRUE(
all(
l, [] (
int x) {
return x > 0; }));
1146 EXPECT_FALSE(
all(
l, [] (
int x) {
return x > 5; }));
1150 EXPECT_TRUE(
all(empty, [] (
int) {
return false; }));
1153TEST(quantifier_test, exists_comprehensive)
1157 EXPECT_TRUE(
exists(
l, [] (
int x) {
return x % 2 == 0; }));
1158 EXPECT_TRUE(
exists(
l, [] (
int x) {
return x == 7; }));
1159 EXPECT_FALSE(
exists(
l, [] (
int x) {
return x > 100; }));
1163 EXPECT_FALSE(
exists(empty, [] (
int) {
return true; }));
1166TEST(quantifier_test, none_comprehensive)
1170 EXPECT_TRUE(
none(
l, [] (
int x) {
return x % 2 == 0; }));
1171 EXPECT_TRUE(
none(
l, [] (
int x) {
return x > 100; }));
1172 EXPECT_FALSE(
none(
l, [] (
int x) {
return x == 5; }));
1176 EXPECT_TRUE(
none(empty, [] (
int) {
return true; }));
1185TEST(scanl_comprehensive, scanl_sum_variants)
1191 EXPECT_EQ(sums, build_dynlist<int>(0, 1, 3, 6, 10, 15));
1195 EXPECT_EQ(sums2, build_dynlist<int>(100, 101, 103, 106, 110, 115));
1200 EXPECT_EQ(empty_scan.size(), 1);
1201 EXPECT_EQ(empty_scan.get_first(), 42);
1204TEST(scanl_comprehensive, scanl_custom_op)
1209 auto products = scanl<int>(
l, 1, [] (
int acc,
int x) {
return acc * x; });
1210 EXPECT_EQ(products, build_dynlist<int>(1, 2, 6, 24));
1213 auto maxes = scanl<int>(
l, 0, [] (
int acc,
int x) {
return std::max(acc, x); });
1214 EXPECT_EQ(maxes, build_dynlist<int>(0, 2, 3, 4));
1219TEST(flat_map_comprehensive, basic_operations)
1228 EXPECT_EQ(result, build_dynlist<int>(0, 0, 1, 0, 1, 2));
1231TEST(flat_map_comprehensive, replicate_pattern)
1238 for (
int i = 0; i < x; ++i)
1242 EXPECT_EQ(result, build_dynlist<int>(1, 2, 2, 3, 3, 3));
1245TEST(flat_map_comprehensive, empty_inner)
1253 return build_dynlist<int>(x);
1255 EXPECT_EQ(result, build_dynlist<int>(1, 3));
1260TEST(concat_comprehensive, various_combinations)
1266 EXPECT_EQ(
concat(a, b), build_dynlist<int>(1, 2, 3, 4, 5));
1267 EXPECT_EQ(
concat(empty, b), build_dynlist<int>(3, 4, 5));
1268 EXPECT_EQ(
concat(a, empty), build_dynlist<int>(1, 2));
1274TEST(while_comprehensive, take_while_various)
1279 auto evens =
take_while(
l, [] (
int x) {
return x % 2 == 0; });
1280 EXPECT_EQ(evens, build_dynlist<int>(2, 4, 6));
1283 auto small =
take_while(
l, [] (
int x) {
return x < 5; });
1284 EXPECT_EQ(small, build_dynlist<int>(2, 4));
1287 auto none_taken =
take_while(
l, [] (
int x) {
return x > 100; });
1288 EXPECT_TRUE(none_taken.is_empty());
1291 auto all_taken =
take_while(
l, [] (
int) {
return true; });
1292 EXPECT_EQ(all_taken.size(),
l.
size());
1295TEST(while_comprehensive, drop_while_various)
1300 auto after_evens =
drop_while(
l, [] (
int x) {
return x % 2 == 0; });
1301 EXPECT_EQ(after_evens, build_dynlist<int>(7, 8, 10));
1304 auto after_small =
drop_while(
l, [] (
int x) {
return x < 5; });
1305 EXPECT_EQ(after_small, build_dynlist<int>(6, 7, 8, 10));
1308 auto none_dropped =
drop_while(
l, [] (
int x) {
return x > 100; });
1309 EXPECT_EQ(none_dropped.size(),
l.
size());
1312 auto all_dropped =
drop_while(
l, [] (
int) {
return true; });
1313 EXPECT_TRUE(all_dropped.is_empty());
1318TEST(reverse_comprehensive, various_sizes)
1320 EXPECT_EQ(
reverse(build_dynlist<int>(1)), build_dynlist<int>(1));
1321 EXPECT_EQ(
reverse(build_dynlist<int>(1, 2)), build_dynlist<int>(2, 1));
1322 EXPECT_EQ(
reverse(build_dynlist<int>(1, 2, 3)), build_dynlist<int>(3, 2, 1));
1325 EXPECT_TRUE(
reverse(empty).is_empty());
1334TEST(min_max_ptr_comprehensive, with_comparator)
1342 auto * shortest =
min_ptr(names, [] (
const string & a,
const string & b) {
1343 return a.
length() < b.length();
1345 ASSERT_NE(shortest,
nullptr);
1346 EXPECT_EQ(*shortest,
"Bob");
1348 auto * longest =
max_ptr(names, [] (
const string & a,
const string & b) {
1349 return a.
length() < b.length();
1351 ASSERT_NE(longest,
nullptr);
1352 EXPECT_EQ(*longest,
"Charlie");
1355TEST(min_max_ptr_comprehensive, minmax_combined)
1357 DynList<int> l = build_dynlist<int>(3, 1, 4, 1, 5, 9, 2, 6);
1360 ASSERT_NE(min_p,
nullptr);
1361 ASSERT_NE(max_p,
nullptr);
1362 EXPECT_EQ(*min_p, 1);
1363 EXPECT_EQ(*max_p, 9);
1368TEST(fold_comprehensive, foldl_associativity)
1376 auto result = foldl<string>(words,
"START", [] (
const string & acc,
const string & x) {
1377 return "(" + acc +
"+" + x +
")";
1379 EXPECT_EQ(result,
"(((START+a)+b)+c)");
1382TEST(fold_comprehensive, foldr_associativity)
1390 auto result = foldr<string>(words,
"END", [] (
const string & x,
const string & acc) {
1391 return "(" + x +
"+" + acc +
")";
1393 EXPECT_EQ(result,
"(a+(b+(c+END)))");
1398TEST(zip_comprehensive, different_lengths)
1406 auto zipped =
zip(a, b);
1407 EXPECT_EQ(zipped.size(), 2);
1410TEST(zip_comprehensive, zip_all_predicate)
1416 bool all_double =
zip_all([] (
auto t) {
return get<1>(t) == 2 * get<0>(t); }, a, b);
1417 EXPECT_TRUE(all_double);
1420 bool not_all =
zip_all([] (
auto t) {
return get<1>(t) == 2 * get<0>(t); }, a, c);
1421 EXPECT_FALSE(not_all);
1426TEST(group_by_comprehensive, custom_key)
1428 DynList<int> l = build_dynlist<int>(1, 3, 5, 2, 4, 6, 7, 9);
1431 auto groups =
group_by(
l, [] (
int x) {
return x % 2; });
1433 EXPECT_EQ(groups.size(), 3);
1435 auto it = groups.get_it();
1436 EXPECT_EQ(it.get_curr().first, 1);
1437 EXPECT_EQ(it.get_curr().second.size(), 3);
1439 EXPECT_EQ(it.get_curr().first, 0);
1440 EXPECT_EQ(it.get_curr().second.size(), 3);
1442 EXPECT_EQ(it.get_curr().first, 1);
1443 EXPECT_EQ(it.get_curr().second.size(), 2);
1448TEST(functional_performance, large_chain)
1450 constexpr size_t N = 10000;
1451 auto large = range<int>(0,
static_cast<int>(
N) - 1);
1454 auto evens =
filter(large, [] (
int x) {
return x % 2 == 0; });
1455 auto squared = maps<int>(evens, [] (
int x) {
return x * x; });
1460 for (
auto it = squared.get_it(); it.has_curr() &&
count < 100; it.next_ne(), ++
count)
1461 first100.
append(it.get_curr());
1465 for (
int i = 0; i < 100; ++i)
1468 auto total = foldl<long long>(first100, 0
LL, [] (
long long acc,
int x) {
1474TEST(functional_performance, deep_nesting)
1478 auto result = maps<int>(
1480 maps<int>(
l, [] (
int x) {
return x + 1; }),
1481 [] (
int x) {
return x * 2; }),
1482 [] (
int x) {
return x - 1; });
1485 EXPECT_EQ(result, build_dynlist<int>(1, 3, 5, 7, 9));
1502 if (a.size() != b.size())
return false;
1503 for (
size_t i = 0; i < a.size(); ++i)
1505 const auto ca =
static_cast<unsigned char>(a[i]);
1506 const auto cb =
static_cast<unsigned char>(b[i]);
1507 if (std::tolower(ca) != std::tolower(cb))
return false;
1525 lower.reserve(s.size());
1527 lower.push_back(
static_cast<char>(std::tolower(
static_cast<unsigned char>(c))));
1528 return std::hash<string>()(lower);
1558TEST(all_unique_overload, case_insensitive_strings_true)
1561 auto strings = build_dynlist<string>(
"Hello",
"World",
"Test",
"Aleph");
1565TEST(all_unique_overload, case_insensitive_strings_false)
1568 auto strings = build_dynlist<string>(
"hello",
"World",
"HELLO",
"Test");
1572TEST(all_unique_overload, float_tolerance_true)
1575 auto floats = build_dynlist<float>(1.0f, 1.1f, 1.2f, 1.3f);
1579TEST(all_unique_overload, float_tolerance_false)
1582 auto floats = build_dynlist<float>(1.0f, 1.01f, 1.5f, 2.0f);
1586TEST(all_unique_overload, default_equality_true)
1589 auto ints = build_dynlist<int>(1, 2, 3, 4, 5);
1593TEST(all_unique_overload, default_equality_false)
1596 auto ints = build_dynlist<int>(1, 2, 3, 2, 5);
1600TEST(all_unique_overload, rvalue_comparator_false_case)
1603 EXPECT_FALSE(
all_unique(build_dynlist<string>(
"Apple",
"apple",
"Banana"),
1607TEST(all_unique_overload, rvalue_comparator_true_case)
1610 EXPECT_TRUE(
all_unique(build_dynlist<string>(
"Apple",
"Banana",
"Cherry"),
1614TEST(all_unique_overload, custom_hash_and_eq_true)
1616 auto strings = build_dynlist<string>(
"Hello",
"World",
"Test",
"Aleph");
1622TEST(all_unique_overload, custom_hash_and_eq_false)
1624 auto strings = build_dynlist<string>(
"hello",
"World",
"HELLO",
"Test");
1630TEST(all_unique_overload, custom_hash_and_eq_lvalue_functors)
1632 auto strings = build_dynlist<string>(
"Alpha",
"Bravo",
"alpha");
1638TEST(all_unique_overload, custom_hash_functor_is_invoked)
1640 auto strings = build_dynlist<string>(
"Alpha",
"Bravo",
"ALPHA");
1641 size_t hash_calls = 0;
1643 auto hash = [&hash_calls] (
const string & s) ->
size_t
1651 EXPECT_GT(hash_calls, 0u);
1654TEST(all_unique_overload, empty_container)
1658 EXPECT_TRUE(
all_unique(empty, std::hash<int>(), std::equal_to<int>()));
1659 EXPECT_TRUE(
all_unique(empty, std::equal_to<int>()));
1663TEST(all_unique_overload, single_element)
1666 auto single = build_dynlist<int>(42);
1667 EXPECT_TRUE(
all_unique(single, std::hash<int>(), std::equal_to<int>()));
1668 EXPECT_TRUE(
all_unique(single, std::equal_to<int>()));
1680 struct From_Int_May_Throw
1682 static inline bool fail =
false;
1684 From_Int_May_Throw(
const int x) : v(x)
1687 throw std::runtime_error(
"the conversion fails");
1691 struct Default_May_Throw
1693 static inline bool fail =
false;
1697 throw std::runtime_error(
"the default construction fails");
1703 explicit No_Default(
int) {}
1716 std::declval<const std::string &>())));
1718 std::declval<const int &>())));
1722 static_assert(std::is_same_v<std::invoke_result_t<Dft_Map_Op<long, int>,
const int &>,
long>);
1723 static_assert(std::is_same_v<std::invoke_result_t<Dft_Map_Op<std::string, std::string>,
const std::string &>,
1728 static_assert(std::invocable<Dft_Map_Op<double, int>,
const int &>);
1729 static_assert(std::invocable<Dft_Map_Op<Unrelated, Unrelated>,
const Unrelated &>);
1730 static_assert(not std::invocable<Dft_Map_Op<Unrelated, int>,
const int &>);
1731 static_assert(not std::invocable<Dft_Map_Op<int, Unrelated>,
const Unrelated &>);
1732 static_assert(not std::is_nothrow_invocable_v<Dft_Map_Op<Unrelated, int>,
const int &>);
1733 static_assert(std::invocable<Dft_Fold_Op<int, std::string>,
const int &,
const std::string &>);
1734 static_assert(not std::invocable<Dft_Fold_Op<No_Default, int>,
const No_Default &,
const int &>);
1737TEST(default_operations, what_they_build_may_throw)
1739 From_Int_May_Throw::fail =
true;
1741 From_Int_May_Throw::fail =
false;
1744 const Default_May_Throw acc;
1745 Default_May_Throw::fail =
true;
1747 Default_May_Throw::fail =
false;
1751TEST(default_operations, what_they_return)
1757 EXPECT_EQ(kept, std::string(40,
'x'));
TEST_F(TreeContainer, pointers)
String manipulation utilities.
Zip iterators and functional operations for multiple containers.
Functional programming utilities for Aleph-w containers.
T & append()
Allocate a new entry to the end of array.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
T & get_last()
Return the last item of the list.
size_t size() const noexcept
Return the number of items of the list, in constant time.
Dynamic set backed by balanced binary search trees with automatic memory management.
const size_t & size() const
Returns the cardinality of the set.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
Number Theoretic Transform over Z / MOD Z.
Minimal std::expected-style result type for C++20.
size_t length() const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, T >)
Count the number of elements of a container.
bool all(Operation &operation) const
Check if all the elements of the container satisfy a condition.
Aleph::DynList< T > take(const size_t n) const
Return a list with the first n elements seen in the container during its traversal.
Aleph::DynList< T > drop(const size_t n) const
Drop the first n elements seen in the container during its traversal.
Type & nth(const size_t n)
Return the n-th item of the container.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
MapOLhash< int, Foo > tbl
Main namespace for Aleph-w library functions.
std::pair< DynList< T >, size_t > unique_sequential(const Container< T > &c, Equal &eq)
Extract unique consecutive items.
std::tuple< bool, size_t, typename C1::Item_Type, typename C2::Item_Type > are_eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Detailed equality check returning mismatch position and values.
DynList< T > flatten(const C2< C1< T > > &c)
Flatten a nested container of one level.
DynList< typename Container::Item_Type > to_dynlist(const Container &c)
void each(const size_t start, const size_t end, Op &op)
Execute an operation repeatedly over a range of indices.
Container< T > nrange(const T start, const T end, const size_t n)
Generate exactly n values evenly spaced between [start, end].
auto group_by_reduce(const Container< T > &c, KeyFunc key_func, Reducer reducer) -> DynList< std::pair< std::invoke_result_t< KeyFunc, const T & >, std::invoke_result_t< Reducer, const DynList< T > & > > >
Group consecutive elements and apply a reducer to each group.
DynList< std::pair< std::optional< typename Container1::Item_Type >, std::optional< typename Container2::Item_Type > > > zip_longest_opt(const Container1 &a, const Container2 &b)
Zip two containers using optionals for missing values.
auto unzip(const Container &l)
Separate a list of pairs into two lists.
void reverse(Itor beg, Itor end)
Reverse elements in a range.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
auto set_range(const T start, const T end, const T step, Op &op) -> Container< std::decay_t< decltype(op(start))> >
Generate a range [start, end] and apply an operation to each value.
DynList< std::pair< typename Container1::Item_Type, typename Container2::Item_Type > > zipEq(const Container1 &a, const Container2 &b)
Zip two containers; throw if lengths differ.
size_t size(Node *root) noexcept
See compute_cardinality_rec(Node * root).
void enum_for_each(const Container &container, Operation &operation)
Apply an operation to each element and its index.
std::pair< TgtContainer< typename SrcContainer::Item_Type >, TgtContainer< typename SrcContainer::Item_Type > > partition(const SrcContainer &c, std::function< bool(const typename SrcContainer::Item_Type &)> operation)
Partition a container into two based on a predicate.
bool containers_eq(const C1 &c1, const C2 &c2, Eq e)
See eq.
bool all_unique(const Container &container, Equal &eq)
Check if all elements in a container are unique using a comparator.
Container2< typename Container1::Item_Type > filter(Container1 &container, Operation &operation)
Filter elements that satisfy operation.
size_t remove_from_container(C &c, Args... args)
Remove multiple items from a container.
bool is_inside(const T &val, const DynList< T > &values)
Check if a value is present in a list.
std::string concat(const Args &...args)
Concatenate multiple arguments into a single std::string.
const Container::Item_Type * max_ptr(const Container &container, Cmp cmp=Cmp())
Find the maximum element in a container.
DynList< std::pair< typename Container1::Item_Type, typename Container2::Item_Type > > zip(const Container1 &a, const Container2 &b)
Zip two containers into a list of pairs.
bool all(Container &container, Operation &operation)
Return true if all elements satisfy a predicate.
auto enumerate(const Container &c)
Return pairs of (element, index).
bool is_equal(const T &val)
Variadic check for equality against multiple values.
bool exists(Container &container, Operation &operation)
Return true if at least one element satisfies a predicate.
auto gen_seq_list_tuples(const Container &c, size_t n)
Generate all sequential tuples (sliding windows) of size n.
bool contains(const std::string_view &str, const std::string_view &substr)
Check if substr appears inside str.
DynList< T > rep(const size_t n, const T &item)
Create a sequence of repeated items.
auto flat_map(const Container &container, Op op) -> DynList< typename std::decay_t< decltype(op(std::declval< typename Container::Item_Type >()))>::Item_Type >
Apply operation and flatten results (flatMap/concatMap).
DynList< std::tuple< typename Container1::Item_Type, typename Container2::Item_Type > > tzip(const Container1 &a, const Container2 &b)
Zip two containers into a list of tuples.
bool zip_all(Op &&op, const Cs &...cs)
Return true if op returns true for all tuples and containers have equal length.
T product(const Container &container, const T &init=T{1})
Compute product of all elements.
bool diff(const C1 &c1, const C2 &c2, Eq e=Eq())
Check if two containers differ.
and PredicateWith< Cmp &, const typename Container::Item_Type &, functional_detail::get_curr_cref_t< Container > > std::pair< const typename Container::Item_Type *, const typename Container::Item_Type * > minmax_ptr(const Container &container, Cmp cmp=Cmp())
Find both min and max elements in a single pass.
DynList< typename Container::Item_Type * > pointers_list(Container &c)
Create a list of pointers to items in a container.
DynList< std::pair< size_t, typename Container::Key_Type > > indexes(const Container &c)
Return pairs of (index, key).
bool lesser(const C1 &c1, const C2 &c2, Cmp cmp=Cmp())
Lexicographical comparison between two containers.
DynList< typename Container::Item_Type > take_while(const Container &c, Pred pred)
Return elements while predicate is true (take_while).
size_t append_in_container(C &c, Args &&... args)
Append multiple items into a container.
TgtC assign_container(const SrcC &srcc)
Convert one container type to another.
DynList< std::tuple< size_t, typename Container::Item_Type > > enumerate_tuple(const Container &container)
Zip containers with an index (enumerate with zip).
DynList< std::tuple< typename Container1::Item_Type, typename Container2::Item_Type > > tzipEq(const Container1 &a, const Container2 &b)
Zip two containers into tuples; throw if lengths differ.
Operation for_each(Itor beg, const Itor &end, Operation op)
Apply an operation to each element in a range.
std::pair< DynList< DynList< T > >, size_t > sequential_groups(const Container< T > &c, Equal &eq)
Group consecutive equal elements together.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
DynList< std::tuple< size_t, typename Container::Key_Type > > tindexes(const Container &c)
Return tuples of (index, key).
Itor::difference_type count_if(Itor beg, const Itor &end, Operation op)
Count elements satisfying a predicate.
DynList< T > scanl_sum(const Container &container, const T &init)
Compute running sums (scanl with addition).
DynList< std::tuple< typename Container1::Item_Type, typename Container2::Item_Type > > tzip_longest(const Container1 &a, const Container2 &b, const typename Container1::Item_Type &fill_a=typename Container1::Item_Type(), const typename Container2::Item_Type &fill_b=typename Container2::Item_Type())
Zip two containers into tuples, padding the shorter one.
DynList< std::pair< typename Container1::Item_Type, typename Container2::Item_Type > > zip_longest(const Container1 &a, const Container2 &b, const typename Container1::Item_Type &fill_a=typename Container1::Item_Type(), const typename Container2::Item_Type &fill_b=typename Container2::Item_Type())
Zip two containers, padding the shorter one with a fill value.
DynList< typename Container::Item_Type > sublist(const Container &c, size_t pos, const size_t stride)
Extract a sublist using a stride.
Container::Item_Type * find_ptr(Container &container, Pred &pred)
Find the first element satisfying pred.
Container< T > range(const T start, const T end, const T step=1)
Generate a range of values [start, end] with a given step.
DynList< std::pair< std::invoke_result_t< KeyFunc, const T & >, DynList< T > > > group_by(const Container< T > &c, KeyFunc key_func)
Group consecutive elements by a key function.
Container< T > contiguous_range(T start, const size_t n)
Generate n contiguous values starting from start.
DynList< T > build_dynlist(Args &&... args)
Build a DynList with the given items; an rvalue is moved.
bool none(const Container &container, Operation &operation)
Return true if no element satisfies operation.
auto get_pair_it(C1 &c1, C2 &c2)
Create a Pair_Iterator for two containers.
DynList< typename Container::Item_Type > drop_while(const Container &c, Pred pred)
Skip elements while predicate is true (drop_while).
const Container::Item_Type * min_ptr(const Container &container, Cmp cmp=Cmp())
Find the minimum element in a container.
size_t insert_in_container(C &c, Args &&... args)
Insert multiple items into a container.
std::tuple< Container< T1 >, Container< T2 > > tunzip(const Container< std::tuple< T1, T2 > > &l)
Separate a list of tuples into two containers.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Default folding operation (returns default-constructed accumulator).
Default mapping operation: the conversion of the item, which is its copy when the two types are the s...
Represents a missing value.
bool is_found() const noexcept override
Represents a found value (stored by reference).
bool is_found() const noexcept override
bool operator()(const string &a, const string &b) const
Performs a case-insensitive comparison of two strings.
size_t operator()(const string &s) const
Produces a case-insensitive hash for a string by hashing its lowercase form.
Helper for float comparison with tolerance.
bool operator()(float a, float b) const
Compares two floating-point values for equality within the configured tolerance.
FloatToleranceEqual(float tol=0.001f)
Constructs a FloatToleranceEqual comparator with a specified tolerance.
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >())
Traverse the container via its iterator and performs a conditioned operation on each item.
bool operator==(const Person &other) const
Lazy and scalable dynamic array implementation.
Dynamic set implementations based on hash tables.
Dynamic set implementations based on balanced binary search trees.
Open addressing hash table with double hashing.