8#include <gtest/gtest.h>
24 vector<int> v = {1, 2, 3, 4, 5};
32 vector<int> v = {1, 2, 3};
55 vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8};
57 [](
int x) { return x % 2 == 0; });
63 vector<int> v = {1, 3, 5, 7, 9};
65 [](
int x) { return x % 2 == 0; });
71 vector<int> v = {2, 4, 6, 8};
73 [](
int x) { return x % 2 == 0; });
79 vector<int> v = {1, 2, 3, 2, 4, 2, 5};
86 vector<int> v = {1, 2, 3, 4, 5};
97 vector<int> v = {5, 2, 8, 1, 9};
112 vector<int> v = {5, 2, 8, 1, 9};
124 vector<int> v = {1, 3, 5, 4, 7, 8};
126 [](
int x) { return x % 2 == 0; });
133 vector<int> v = {1, 3, 5, 7, 9};
135 [](
int x) { return x % 2 == 0; });
141 vector<int> v = {1, 2, 3, 4, 5};
149 vector<int> v = {1, 2, 3, 4, 5};
160 vector<int> v = {1, 2, 2, 2, 3, 4};
168 vector<int> v = {1, 2, 2, 3, 2, 2, 4};
175 vector<int> v = {1, 2, 3};
186 vector<int> v = {1, 2, 3, 3, 4, 5};
194 vector<int> v = {1, 2, 3, 4, 5};
212 vector<int> v1 = {1, 2, 3, 4, 5};
213 vector<int> v2 = {1, 2, 3, 4, 5};
219 vector<int> v1 = {1, 2, 3, 4, 5};
220 vector<int> v2 = {1, 2, 3, 4, 6};
230 vector<int> v1 = {1, 2, 3};
231 vector<int> v2 = {1, 2, 4};
233 v1.begin(), v1.end(), v2.begin(), v2.end()));
238 vector<int> v1 = {1, 2, 4};
239 vector<int> v2 = {1, 2, 3};
241 v1.begin(), v1.end(), v2.begin(), v2.end()));
246 vector<int> v1 = {1, 2};
247 vector<int> v2 = {1, 2, 3};
249 v1.begin(), v1.end(), v2.begin(), v2.end()));
258 vector<int> src = {1, 2, 3};
259 vector<int>
dst(3, 0);
270 vector<int> src = {1, 2, 3};
271 vector<int>
dst(3, 0);
286 vector<int> src = {1, 2, 3};
287 vector<int>
dst(3, 0);
290 [](
int x) { return x * 2; });
299 vector<int>
src1 = {1, 2, 3};
300 vector<int>
src2 = {10, 20, 30};
301 vector<int>
dst(3, 0);
304 [](
int a,
int b) { return a + b; });
317 vector<int> v1 = {1, 2, 3};
318 vector<int> v2 = {4, 5, 6};
336 vector<int> v = {1, 2, 3};
347 vector<int> v = {1, 2, 3, 4, 5};
367 Aleph::generate(v.begin(), v.end(), [&counter]() { return ++counter; });
393 vector<int> v = {1, 2, 3, 4, 5};
396 [](
int x) { return x % 2 == 0; }, 0);
407 vector<int> v = {1, 2, 1, 3, 1};
424 vector<int> src = {1, 2, 3, 4, 5};
425 vector<int>
dst(5, 0);
428 [](
int x) { return x % 2 == 0; }, 0);
443 vector<int> v = {1, 2, 3, 4, 5};
456 vector<int> v = {42};
475 vector<int> src = {1, 2, 3, 4, 5};
476 vector<int>
dst(5, 0);
493 vector<int> v = {1, 2, 3, 4, 5};
510 vector<int> v = {1, 2, 4, 5, 6};
518 vector<int> v = {1, 2, 4, 5, 6};
526 vector<int> v = {1, 2, 4, 5, 6};
538 vector<int> v = {1, 2, 3, 4, 5};
544 vector<int> v = {1, 2, 3, 4, 5};
554 vector<int> v = {1, 2, 2, 2, 3, 4};
567 vector<int> v1 = {1, 2, 3, 4, 5, 6, 7};
568 vector<int> v2 = {2, 4, 6};
574 vector<int> v1 = {1, 2, 3, 4, 5};
575 vector<int> v2 = {2, 4, 8};
581 vector<int> v1 = {1, 2, 3};
592 vector<int> v1 = {1, 3, 5};
593 vector<int> v2 = {2, 4, 6};
594 vector<int> result(6, 0);
596 Aleph::merge(v1.begin(), v1.end(), v2.begin(), v2.end(), result.begin());
608 vector<int> v1 = {1, 2, 3};
610 vector<int> result(3, 0);
612 Aleph::merge(v1.begin(), v1.end(), v2.begin(), v2.end(), result.begin());
625 vector<int> v = {1, 2, 3, 4, 5};
632 vector<int> v = {1, 2, 3, 4, 5};
634 [](
int a,
int b) { return a * b; });
640 vector<int> v = {1, 2, 3};
658 vector<int> v1 = {1, 2, 3};
659 vector<int> v2 = {4, 5, 6};
667 vector<int> v1 = {1, 2, 3};
668 vector<int> v2 = {1, 1, 1};
672 [](
int a,
int b) { return a + b; },
673 [](
int a,
int b) { return a - b; });
683 vector<int> src = {1, 2, 3, 4, 5};
684 vector<int>
dst(5, 0);
697 vector<int> src = {1, 2, 3, 4};
698 vector<int>
dst(4, 0);
701 [](
int a,
int b) { return a * b; });
724 vector<int> src = {1, 3, 6, 10, 15};
725 vector<int>
dst(5, 0);
738 vector<int> src = {1, 2, 4, 8};
739 vector<int>
dst(4, 0);
742 [](
int a,
int b) { return a / b; });
756 vector<int> v = {1, 1, 2, 2, 2, 3, 3};
763 EXPECT_EQ(std::distance(v.begin(), it), 3);
768 vector<int> v = {1, 2, 3, 4};
780 vector<int> v = {1, 2, 3, 4, 5, 6};
783 [](
int x) { return x % 2 == 0; });
788 EXPECT_EQ(std::distance(v.begin(), it), 3);
793 vector<int> v = {1, 2, 1, 3, 1};
799 EXPECT_EQ(std::distance(v.begin(), it), 2);
808 vector<int> src = {1, 2, 3, 4, 5, 6};
813 std::back_inserter(
dst),
814 [](
int x) { return x % 2 == 0; });
829 vector<int> src = {1, 1, 2, 2, 3, 3};
846 vector<int> v = {42};
862 for (
int i = 0; i <
N; ++i)
867 [](
int x) { return x % 2 == 0; });
881 vector<int> v1 = {1, 2, 3, 4, 5};
882 vector<int> v2 = {1, 2, 3, 9, 5};
892 vector<int> v1 = {1, 2, 3};
893 vector<int> v2 = {1, 2, 3};
906 vector<int> v = {1, 2, 3, 4, 5, 6};
907 vector<int> sub = {3, 4, 5};
909 auto it =
Aleph::search(v.begin(), v.end(), sub.begin(), sub.end());
917 vector<int> v = {1, 2, 3, 4, 5};
918 vector<int> sub = {3, 5, 4};
920 auto it =
Aleph::search(v.begin(), v.end(), sub.begin(), sub.end());
Aleph-w implementation of STL-like algorithms.
size_t size() const noexcept
Count the number of elements of the list.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
Main namespace for Aleph-w library functions.
Itor lower_bound(Itor beg, Itor end, const T &value)
Find lower bound in a sorted range.
std::pair< Itor1, Itor2 > mismatch(Itor1 beg, const Itor1 &end, Itor2 cmpBeg, BinaryPredicate op=BinaryPredicate())
Find the first mismatching elements in two ranges.
void reverse(Itor beg, Itor end)
Reverse elements in a range.
Itor unique(Itor __first, Itor __last, BinaryPredicate __binary_pred=BinaryPredicate())
Remove consecutive duplicates in place.
Itor2 partial_sum(Itor1 sourceBeg, Itor1 sourceEnd, Itor2 destBeg)
Compute partial sums of a range.
Itor2 copy_backward(const Itor1 &sourceBeg, Itor1 sourceEnd, Itor2 destEnd)
Copy elements backward from one range to another.
void generate(Itor beg, const Itor &end, Func op)
Generate values for a range.
T inner_product(Itor1 beg1, Itor1 end1, Itor2 beg2, T initValue)
Compute inner product of two ranges.
void replace_if(Itor beg, const Itor &end, UnaryPredicate op, const T &value)
Replace elements satisfying a predicate.
Out_Itor unique_copy(In_Itor __first, In_Itor __last, Out_Itor __result)
Copy unique elements.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
bool lexicographical_compare(Itor1 beg1, const Itor1 &end1, Itor2 beg2, const Itor2 &end2, Comp op=Comp())
Lexicographical comparison of two ranges.
void fill(Itor beg, const Itor &end, const T &value)
Fill a range with a value.
Out_Itor remove_copy_if(In_Itor __first, const In_Itor &__last, Out_Itor __result, Predicate __pred)
Copy elements not satisfying a predicate.
Itor2 adjacent_difference(Itor1 sourceBeg, Itor1 sourceEnd, Itor2 destBeg)
Compute adjacent differences.
Itor adjacent_find(Itor beg, const Itor &end, BinaryPredicate op=BinaryPredicate())
Find first pair of adjacent equal elements.
T accumulate(Itor beg, Itor end, T initValue)
Accumulate values in a range.
Itor find(const Itor &beg, const Itor &end, const T &value)
Find the first element equal to a value.
Itor2 swap_ranges(Itor1 beg1, const Itor1 &end1, Itor2 beg2)
Swap elements between two ranges.
Itor min_element(Itor beg, const Itor &end, CompFunc op=CompFunc())
Find the minimum element in a range.
Itor2 replace_copy_if(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg, UnaryPredicate op, const T &value)
Copy and replace elements satisfying a predicate.
T product(const Container &container, const T &init=T{1})
Compute product of all elements.
Itor upper_bound(Itor beg, Itor end, const T &value)
Find upper bound in a sorted range.
Fw_Itor remove(Fw_Itor __first, const Fw_Itor &__last, const T &__value)
Remove elements equal to a value.
Itor search_n(Itor beg, const Itor &end, Size count, const T &value, BinaryPredicate op=BinaryPredicate())
Find n consecutive elements equal to a value.
Itor1 search(Itor1 beg, const Itor1 &end, Itor2 searchBeg, const Itor2 &searchEnd, BinaryPredicate op=BinaryPredicate())
Search for a subrange within a range.
bool equal(Itor1 beg, const Itor1 &end, Itor2 cmpBeg, BinaryPredicate op=BinaryPredicate())
Test if two ranges are equal.
Itor2 transform(Itor1 sourceBeg, Itor1 sourceEnd, Itor2 destBeg, UnaryFunc op)
Transform elements using a unary operation.
Operation for_each(Itor beg, const Itor &end, Operation op)
Apply an operation to each element in a range.
void fill_n(Itor beg, Size num, const T &value)
Fill n elements with a value.
Fw_Itor remove_if(Fw_Itor __first, const Fw_Itor &__last, Predicate __pred)
Remove elements satisfying a predicate.
Itor3 merge(Itor1 source1Beg, Itor1 source1End, Itor2 source2Beg, Itor2 source2End, Itor3 destBeg)
Merge two sorted ranges.
bool binary_search(Itor beg, Itor end, const T &value)
Binary search for a value.
Itor::difference_type count_if(Itor beg, const Itor &end, Operation op)
Count elements satisfying a predicate.
void generate_n(Itor beg, Size num, Func op)
Generate values for n elements.
bool includes(Itor1 beg, Itor1 end, Itor2 searchBeg, Itor2 searchEnd)
Test if one sorted range includes another.
std::pair< Itor, Itor > equal_range(Itor beg, Itor end, const T &value)
Find equal range in a sorted sequence.
Itor2 reverse_copy(Itor1 sourceBeg, Itor1 sourceEnd, Itor2 destBeg)
Copy elements in reverse order.
Container< T > range(const T start, const T end, const T step=1)
Generate a range of values [start, end] with a given step.
Itor max_element(const Itor &beg, const Itor &end, CompFunc op=CompFunc())
Find the maximum element in a range.
void replace(Itor beg, const Itor &end, const T &old_value, const T &new_value)
Replace elements equal to a value.
Itor find_if(Itor beg, const Itor &end, UnaryPredicate op)
Find the first element satisfying a predicate.
void rotate(Itor beg, Itor pos, Itor end)
Rotate elements in a range.
DynList< T > maps(const C &c, Op op)
Classic map operation.
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.
Dynamic array container with automatic resizing.
Dynamic doubly linked list implementation.