48#include <gtest/gtest.h>
70 std::vector<std::vector<int>>
seen;
78 std::vector<int> ref = {1, 2, 3, 4};
82 while (std::next_permutation(ref.begin(), ref.end()));
94 std::vector<std::vector<int>>
eager;
95 std::vector<int> ref = {1, 2, 3};
96 std::sort(ref.begin(), ref.end());
99 while (std::next_permutation(ref.begin(), ref.end()));
101 std::vector<std::vector<int>> lazy;
103 lazy.push_back(
vec_of(p));
110 std::vector<int> ref = {1, 1, 2};
111 std::sort(ref.begin(), ref.end());
115 while (std::next_permutation(ref.begin(), ref.end()));
127 std::set<std::vector<int>>
seen;
147 std::vector<std::vector<int>>
seen;
156 std::vector<std::vector<int>>
seen;
176 for (
size_t k = 0;
k <= a.size(); ++
k)
188 const size_t n = a.
size();
194 std::vector<std::vector<int>>
expected;
195 for (
uint64_t mask = 0; mask < (1u << n); ++mask)
197 if (
static_cast<size_t>(std::popcount(mask)) !=
k)
199 std::vector<int>
combo;
200 for (
size_t i = 0; i < n; ++i)
201 if (mask & (1u << i))
202 combo.push_back(a[i]);
207 std::vector<std::vector<int>>
got;
210 std::sort(
got.begin(),
got.end());
218 std::set<std::vector<int>>
seen;
227 std::vector<std::vector<char>>
seen;
230 EXPECT_EQ(
seen, (std::vector<std::vector<char>>{{
'a',
'b'}, {
'a',
'c'}, {
'b',
'c'}}));
Lazy (coroutine-based) permutation and combination enumeration.
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
T & insert(const T &data)
insert a copy of data at the beginning of the array.
Lazy, single-pass sequence of T values produced by a coroutine.
iterator begin() &
Begin iterating: resumes the coroutine to its first co_yield.
Minimal std::expected-style result type for C++20.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
Aleph::Generator< Array< T > > lazy_permutations(Array< T > a, Compare cmp=Compare())
Lazily enumerate all permutations of a, in lexicographic order.
size_t combination_count(size_t n, size_t k)
Compute n choose k with overflow checks.
Aleph::Generator< Array< T > > lazy_combinations(Array< T > a, size_t k)
Lazily enumerate all k-element combinations of a's elements.
std::vector< typename Container::Item_Type > to_stdvector(const Container &c)
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.