38# include <gtest/gtest.h>
52 std::ostringstream
oss;
130 std::set<std::string>
perms;
171 std::set<std::string> s;
189 std::set<std::string> s;
501 std::set<std::string> s;
502 strs.
for_each([&s](
const std::string & v) { s.insert(v); });
513 std::set<std::string>
perms;
545 std::set<std::string>
perms;
560 std::set<std::string>
perms;
580 for (
auto it = t.get_it(); it.has_curr(); it.next_ne(), ++idx)
583 EXPECT_EQ(it.get_curr().get_first(),
static_cast<int>(idx));
Combinatorics utilities: permutations, combinations and matrix transposition.
Functional programming utilities for Aleph-w containers.
size_t size() const noexcept
Return the current dimension of array.
void reserve(const size_t l, const size_t r)
Allocate a range of entries.
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
Insert a new item by copy.
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of the list.
constexpr bool is_empty() const noexcept
Return true if list is empty.
size_t size() const noexcept
Count the number of elements of the list.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
Main namespace for Aleph-w library functions.
bool none_perm(const DynList< DynList< T > > &l, Pred &pred)
Check if no permutation satisfies a predicate.
DynList< DynList< T > > build_combs(const DynList< DynList< T > > &l)
Build the set of unique combinations from a list of lists.
bool all(Container &container, Operation &operation)
Return true if all elements satisfy a predicate.
size_t size(Node *root) noexcept
size_t perm_count(const DynList< DynList< T > > &l)
Count the total number of permutations from a list of lists.
bool traverse_perm(const DynList< DynList< T > > &l, Op &op)
Traverse all the possible permutations that can be done of a list of lists and on each permutation pe...
DynList< DynList< T > > filter_perm(const DynList< DynList< T > > &l, Pred &pred)
Filter permutations that satisfy a predicate.
bool exists(Container &container, Operation &operation)
Return true if at least one element satisfies a predicate.
DynArray< T > sort(const DynArray< T > &a, Cmp &&cmp=Cmp())
Returns a sorted copy of a DynArray.
void for_each_perm(const DynList< DynList< T > > &l, Op &op)
Apply a procedure to every permutation produced by traverse_perm.
DynList< DynList< T > > transpose(const DynList< DynList< T > > &l)
Transpose a matrix represented as a list of lists.
T product(const Container &container, const T &init=T{1})
Compute product of all elements.
DynList< DynList< T > > build_perms(const DynList< DynList< T > > &l)
Materialize all permutations from a list of lists.
void in_place_transpose(C< C< T > > &l)
In-place transpose of a rectangular matrix stored as a nested container.
bool exists_perm(const DynList< DynList< T > > &l, Pred &pred)
Check if any permutation satisfies a predicate.
bool all_perm(const DynList< DynList< T > > &l, Pred &pred)
Check if all permutations satisfy a predicate.
bool none(const Container &container, Operation &operation)
Return true if no element satisfies operation.
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.