87template<
typename T>
class DynList;
92template <
typename T,
typename R>
struct Dft_Map_Op;
115template <
typename Derived,
typename Type>
122 return static_cast<const Derived&
>(*this);
128 return static_cast<Derived&
>(*this);
166 template <
class Operation>
170 for (
typename Derived::Iterator it(
self()); it.has_curr(); it.next_ne())
177 template <
class Operation>
181 for (
typename Derived::Iterator it(
self()); it.has_curr(); it.next_ne())
189 template <
class Operation>
197 template <
class Operation>
226template <
typename Derived,
typename Type>
232 return static_cast<const Derived&
>(*this);
237 return static_cast<Derived&
>(*this);
263 Type * ptr =
nullptr;
265 self().traverse([&ptr, &i, &n] (
Type & item)
294 Type * ptr =
nullptr;
296 self().traverse([&ptr, &i, &n] (
Type & item)
331 template <
class Operation>
335 Type * ptr =
nullptr;
350 template <
class Operation>
354 Type * ptr =
nullptr;
369 template <
class Operation>
377 template <
class Operation>
408 template <
class Operation>
413 return ptr ? std::make_tuple(
true, *ptr) : std::make_tuple(
false,
Type());
417 template <
class Operation>
422 return ptr ? std::make_tuple(
true, *ptr) : std::make_tuple(
false,
Type());
426 template <
class Operation>
434 template <
class Operation>
469template <
typename Derived,
typename Type>
475 return static_cast<const Derived&
>(*this);
480 return static_cast<Derived&
>(*this);
505 template <
class Operation>
518 template <
class Operation>
531 template <
class Operation>
539 template <
class Operation>
561 template <
class Operation>
574 template <
class Operation>
603 template <
class Operation>
611 template <
class Operation>
621 template <
class Operation>
629 template <
class Operation>
654 template <
class Operation>
665 template <
class Operation>
756 template <
typename __Type = Type>
771 template <
typename __Type = Type>
787 template <
class Operation>
800 template <
class Operation>
826 template <
class Operation>
840 template <
class Operation>
862 template <
class Operation>
871 ret_val.append(std::make_tuple(item, i));
878 template <
class Operation>
901 template <
class Operation>
917 template <
class Operation>
927 template <
class Operation>
939 return std::make_tuple(
r1, r2);
943 template <
class Operation>
1084 requires requires(
Type a,
Type b) { { a + b } -> std::convertible_to<Type>; }
1089 result = result + item;
1112 requires requires(
Type a,
Type b) { { a * b } -> std::convertible_to<Type>; }
1117 result = result * item;
1141 const Type * result =
nullptr;
1144 if (result ==
nullptr or item < *result)
1169 const Type * result =
nullptr;
1172 if (result ==
nullptr or *result < item)
1195 template <
class Compare>
1199 const Type * result =
nullptr;
1202 if (result ==
nullptr or cmp(item, *result))
1225 template <
class Compare>
1229 const Type * result =
nullptr;
1232 if (result ==
nullptr or cmp(*result, item))
1264 requires requires(
Type a,
Type b) { { a == b } -> std::convertible_to<bool>; }
1266 return exists([&val] (
const Type & item) {
return item == val; });
1286 template <
class Predicate>
1294 template <
class Predicate>
1316 template <
class Predicate>
1348 const Type * result =
nullptr;
1349 self().traverse([&result] (
const Type & item)
1392 const Type * result =
nullptr;
1447 ret.append(std::make_pair(idx++, item));
1467 template <
class Predicate>
1472 size_t result =
static_cast<size_t>(-1);
1473 self().traverse([&idx, &result, &
pred] (
const Type & item)
1505 requires requires(
Type a,
Type b) { { a == b } -> std::convertible_to<bool>; }
1507 return find_index([&val] (
const Type & item) {
return item == val; });
1536 const Type * prev =
nullptr;
1539 if (prev ==
nullptr or not (*prev == item))
1571 const Type * prev =
nullptr;
1574 if (prev ==
nullptr or not eq(*prev, item))
1636 if (n == 0)
return ret;
1643 current.append(item);
1646 ret.append(std::move(current));
1653 ret.append(std::move(current));
1688 for (
size_t start = 0; start +
size <=
total; start += step)
1692 all.traverse([&window, &idx, start,
size] (
const Type & item)
1694 if (idx >= start
and idx < start +
size)
1695 window.append(item);
1697 return idx < start +
size;
1699 ret.append(std::move(window));
1724 std::vector<Type>
ret;
1725 if constexpr (
requires {
self().size(); })
1749 template <
typename DynListType = DynList<Type>>
1774 template <
typename StringType = std::
string>
1776 requires requires(
Type a) { std::to_string(a); }
1784 ret += std::to_string(item);
1813 ret +=
static_cast<std::string
>(item);
1846 using OtherType =
typename Other::Item_Type;
1849 auto it1 =
self().get_it();
1850 auto it2 =
other.get_it();
1852 while (it1.has_curr()
and it2.has_curr())
1854 ret.append(std::make_pair(it1.get_curr(), it2.get_curr()));
1873template <
typename Derived,
typename Type>
1879 return static_cast<const Derived&
>(*this);
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
CRTP Mixin providing functional programming operations.
Container< __Type > maps(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Derived & self() noexcept
bool all(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
size_t count_if(Predicate pred) const
Count elements satisfying a predicate.
__Type fold_left(std::function< __Type(const __Type &, const Type &)> operation, const __Type &init) const
Left fold with operation first (alternative signature).
Container< Type > drop(const size_t n) const
Skip the first n elements.
Container< std::pair< size_t, Type > > enumerate() const
Enumerate elements with their indices.
bool forall(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Container< Container< Type > > chunk(size_t n) const
Split into chunks of fixed size.
DynListType to_dynlist() const
Convert container to DynList.
std::pair< DynList< Type >, DynList< Type > > partition(Operation &op) const
Partition elements by a predicate.
std::tuple< DynList< Type >, DynList< Type > > tpartition(Operation &op) const
Partition returning tuple instead of pair.
DynList< std::tuple< Type, size_t > > pfilter(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
auto mutable_for_each(Operation &operation) -> decltype(self())
Apply an operation to each element (mutable).
bool none(Predicate &&pred) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Type * min_by(Compare cmp) const
Find the minimum element using a custom comparator.
auto for_each(Operation &&operation=Operation()) -> decltype(self())
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Type * max() const
Find the maximum element.
Container< Type > unique_by(EqPred eq) const
Remove consecutive duplicates using a custom equality predicate.
Type fold(const Type &init, Operation &operation) const
Simple fold with same type for accumulator and elements.
bool none(Predicate &pred) const
Check if no element satisfies a predicate.
Container< Type > rev() const
Create a reversed copy.
bool exists(Operation &operation) const
Test if any element satisfies a predicate.
Container< Container< Type > > sliding(size_t size, size_t step=1) const
Create sliding windows of fixed size.
Container< Type > take(const size_t n) const
Take the first n elements.
std::string join_str(const std::string &sep=", ") const
Join string elements with separator.
Container< Type > unique() const
Remove consecutive duplicate elements.
std::pair< DynList< Type >, DynList< Type > > partition(Operation &&op=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Type fold(const Type &init, Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Type * first() const
Get the first element.
Container< std::pair< Type, typename Other::Item_Type > > zip_with(const Other &other) const
Zip with another container.
Type last_or(const Type &default_val) const
Get the last element or a default value.
auto for_each(Operation &operation) const -> decltype(self())
Apply an operation to each element (read-only).
bool has_value(const Type &val) const
Check if container has a value.
StringType join(const StringType &sep=StringType{", "}) const
Join elements into a string with separator.
size_t index_of(const Type &val) const
Find the index of a specific value.
DynList< std::tuple< Type, size_t > > pfilter(Operation &operation) const
Filter with position information.
__Type foldl(const __Type &init, std::function< __Type(const __Type &, const Type &)> operation) const
Left fold (reduce) with initial value.
bool exists(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Container< __Type > maps(Operation &operation) const
Transform elements using a mapping function.
Type product(const Type &init) const
Compute the product of all elements.
bool all(Operation &operation) const
Test if all elements satisfy a predicate.
auto for_each(Operation &&operation=Operation()) const -> decltype(self())
This is an overloaded member function, provided for convenience. It differs from the above function o...
size_t length() const noexcept
Count the number of elements.
DynList< Type > filter(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Type sum(const Type &init=Type{}) const
Compute the sum of all elements.
size_t find_index(Predicate pred) const
Find the index of the first element satisfying a predicate.
std::vector< Type > to_vector() const
Convert to std::vector.
std::tuple< DynList< Type >, DynList< Type > > tpartition(Operation &&op=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Type * max_by(Compare cmp) const
Find the maximum element using a custom comparator.
const Derived & self() const noexcept
Container< Type > intersperse(const Type &sep) const
Intersperse a separator between elements.
bool forall(Operation &operation) const
Alias for all().
Type first_or(const Type &default_val) const
Get the first element or a default value.
auto mutable_for_each(Operation &&operation=Operation()) -> decltype(self())
This is an overloaded member function, provided for convenience. It differs from the above function o...
auto for_each(Operation &operation) -> decltype(self())
This is an overloaded member function, provided for convenience. It differs from the above function o...
DynList< Type > filter(Operation &operation) const
Filter elements by a predicate.
const Type * last() const
Get the last element.
const Type * min() const
Find the minimum element.
CRTP Mixin for extracting keys from set-like containers.
Container< Type > items() const
Alias for keys().
const Derived & self() const noexcept
Container< Type > keys() const
Extract all keys as a list.
CRTP Mixin providing element location operations.
std::tuple< bool, Type > find_item(Operation &operation) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::tuple< bool, Type > find_item(Operation &operation)
Find element with success flag.
std::tuple< bool, Type > find_item(Operation &&operation=Operation())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Type * find_ptr(Operation and operation=Operation())
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::tuple< bool, Type > find_item(Operation &&operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Type * find_ptr(Operation &operation) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Type * find_ptr(Operation and operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Type & nth_ne(const size_t n) const noexcept
Access the n-th element (unchecked).
const Derived & self() const noexcept
Type * find_ptr(Operation &operation)
Find the first element satisfying a predicate.
Type & nth(const size_t n) const
Access the n-th element (bounds-checked).
Derived & self() noexcept
CRTP Mixin providing traversal operations.
bool traverse(Operation &operation) const
Traverse all elements, applying an operation to each.
const Derived & self() const noexcept
Access the derived class (const version).
bool traverse(Operation and operation=Operation()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool traverse(Operation and operation=Operation())
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool traverse(Operation &operation)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Derived & self() noexcept
Access the derived class (mutable version).
f(args...) is a valid call expression, exactly as written.
f(args...) is a valid call whose result is usable as a condition.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Freq_Node * pred
Predecessor node in level-order traversal.
Main namespace for Aleph-w library functions.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
size_t size(Node *root) noexcept
and
Check uniqueness with explicit hash + equality functors.
static std::atomic< bool > init
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Default mapping operation (identity).