142 template <
class Container,
class T>
144 requires(
Container & c, Modifying_Probe<T> & op) { c.traverse(op); };
151 template <
class Container>
153 requires(
const Container & c,
const typename Container::Key_Type &
k)
156 c.search(
k) ==
nullptr;
168 template <
class Container,
class T>
170 noexcept(std::declval<const Container &>().traverse(std::declval<
Reading_Probe<T> &>()));
179 template <
class Container,
class T>
187 if constexpr (
requires(
It & it) { it.next_ne(); })
188 return noexcept(std::declval<It &>().next_ne());
190 return noexcept(std::declval<It &>().next());
198 if constexpr (
requires(
It & it) { it.get_curr_ne(); })
199 return noexcept(std::declval<It &>().get_curr_ne());
201 return noexcept(std::declval<It &>().get_curr());
216 if constexpr (
requires { it.next_ne(); })
233 decltype(
auto)
current(
It & it)
noexcept(current_is_noexcept<It>)
235 if constexpr (
requires { it.get_curr_ne(); })
236 return it.get_curr_ne();
238 return it.get_curr();
248 using type =
typename C::value_type;
254 requires requires {
typename C::Item_Type; }
257 using type =
typename C::Item_Type;
269 template <
class Op,
class Acc,
class T>
271 requires(Acc & acc, Op & op,
const T & item) { acc = std::invoke(op, std::move(acc), item); }
272 or
requires(Acc & acc, Op & op,
const T & item) { acc = std::invoke(op, acc, item); };
283 template <
class Op,
class Acc,
class T>
285 requires(Acc & acc, Op & op,
const T & item) { acc = std::invoke(op, item, std::move(acc)); }
286 or
requires(Acc & acc, Op & op,
const T & item) { acc = std::invoke(op, item, acc); };
298 template <
class Acc,
class Step>
301 if constexpr (std::is_reference_v<std::invoke_result_t<Step &>>)
304 acc = std::move(
next);
321 template <
class Acc,
class Op,
class T>
324 if constexpr (std::is_invocable_v<Op &, Acc &&, const T &>)
325 assign_fold(acc, [&] () ->
decltype(
auto) {
return std::invoke(op, std::move(acc), item); });
327 assign_fold(acc, [&] () ->
decltype(
auto) {
return std::invoke(op, acc, item); });
337 template <
class Acc,
class Op,
class T>
340 if constexpr (std::is_invocable_v<Op &, const T &, Acc &&>)
341 assign_fold(acc, [&] () ->
decltype(
auto) {
return std::invoke(op, item, std::move(acc)); });
343 assign_fold(acc, [&] () ->
decltype(
auto) {
return std::invoke(op, item, acc); });
361template <
class Container>
367 template <
class Operation,
class Arg,
class Source>
370 using It =
typename Container::Iterator;
371 return std::is_nothrow_constructible_v<It, Source>
372 and
noexcept(std::declval<It &>().has_curr())
373 and Aleph::dry_detail::advance_is_noexcept<It>
374 and Aleph::dry_detail::current_is_noexcept<It>
381 template <
class Deferred>
383 std::conditional_t<std::is_constructible_v<
409 template <
class Operation>
416 for (
typename Container::Iterator it(*
static_cast<Container *
>(
this)); it.has_curr();
434 template <
class Operation>
447 if (not
static_cast<bool>(operation(item)))
462 template <
class Operation>
469 return traverse<Operation>(operation);
481 template <
class Operation>
488 return traverse<Operation>(operation);
505template <
class Container,
class Operation>
508 return c.traverse(op);
525template <
class Container,
class Operation>
528 return c.traverse(op);
553template <
class Container,
typename Type>
563 return static_cast<const Container *
>(
this);
569 template <
class Operation>
573 return requires (Operation & op,
const Type & item)
574 { {
static_cast<bool>(std::invoke(op, item)) }
noexcept; }
575 and Aleph::dry_detail::const_traversal_is_noexcept<C, Type>;
581 template <
class Operation>
585 return requires (Operation & op, Type & item)
586 { {
static_cast<bool>(std::invoke(op, item)) }
noexcept; }
587 and Aleph::dry_detail::mutable_traversal_is_noexcept<C, Type>;
594 template <
class Operation>
597 using TT = std::tuple<bool, Type>;
598 return const_search_is_noexcept<Operation>()
599 and std::is_nothrow_constructible_v<TT, bool, const Type &>
600 and std::is_nothrow_default_constructible_v<Type>
601 and std::is_nothrow_constructible_v<TT, bool, Type>;
606 template <
class Operation>
608 noexcept(const_search_is_noexcept<Operation>())
610 const Type * ptr =
nullptr;
611 const_me()->traverse([&ptr, &operation] (
const Type & item)
613 if (
static_cast<bool>(std::invoke(operation, item)))
626 noexcept(Aleph::dry_detail::const_traversal_is_noexcept<Container, Type>)
628 const Type * ptr =
nullptr;
630 const_me()->traverse([&ptr, &i, n] (
const Type & item)
643 noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept<Container, Type>)
645 Type * ptr =
nullptr;
647 me()->traverse([&ptr, &i, n] (Type & item)
665 return typename Container::Iterator(*
me());
685 [[nodiscard]]
auto get_it(
const size_t pos)
687 auto ret =
typename Container::Iterator(*
me());
688 for (
size_t i = 0; i < pos; ++i)
699 [[nodiscard]]
auto get_it(
const size_t pos)
const
702 for (
size_t i = 0; i < pos; ++i)
732 template <
class C = Container>
735 noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept<C, Type>)
747 const Type &
nth_ne(
const size_t n)
const
748 noexcept(Aleph::dry_detail::const_traversal_is_noexcept<Container, Type>)
772 template <
class C = Container>
774 Type &
nth(
const size_t n)
788 const Type &
nth(
const size_t n)
const
821 template <
class Operation>
825 [[nodiscard]] Type *
find_ptr(Operation & operation)
826 noexcept(mutable_search_is_noexcept<Operation>())
828 Type * ptr =
nullptr;
829 me()->traverse([&ptr, &operation] (Type & item)
831 if (
static_cast<bool>(std::invoke(operation, item)))
848 template <
class Operation>
850 [[nodiscard]]
const Type *
find_ptr(Operation & operation)
const
851 noexcept(const_search_is_noexcept<Operation>())
867 template <
class Operation>
869 [[nodiscard]]
const Type *
find_ptr(Operation && operation)
const
870 noexcept(const_search_is_noexcept<Operation>())
872 return find_ptr<Operation>(operation);
886 template <
class Operation>
890 [[nodiscard]] Type *
find_ptr(Operation && operation)
891 noexcept(mutable_search_is_noexcept<Operation>())
893 return find_ptr<Operation>(operation);
919 template <
class Operation>
922 noexcept(const_search_is_noexcept<Operation>())
925 const_me()->traverse([&i, &operation] (
const Type & item)
927 if (
static_cast<bool>(std::invoke(operation, item)))
946 template <
class Operation>
948 [[nodiscard]]
size_t find_index(Operation && operation)
const
949 noexcept(const_search_is_noexcept<Operation>())
951 return find_index<Operation>(operation);
980 template <
class Operation,
class T = Type>
982 and std::default_initializable<T> and std::copy_constructible<T>
983 [[nodiscard]] std::tuple<bool, Type>
find_item(Operation & operation)
const
984 noexcept(find_item_is_noexcept<Operation>())
986 using TT = std::tuple<bool, Type>;
989 auto ptr =
const_me()->find_ptr(operation);
990 return ptr ?
TT(
true, *ptr) :
TT(
false, Type());
1004 template <
class Operation,
class T = Type>
1006 and std::default_initializable<T> and std::copy_constructible<T>
1007 [[nodiscard]] std::tuple<bool, Type>
find_item(Operation && operation)
const
1008 noexcept(find_item_is_noexcept<Operation>())
1010 return find_item<Operation>(operation);
1025 template <
class Operation,
class T = Type>
1027 and std::copy_constructible<T>
1028 [[nodiscard]] std::optional<Type>
find_opt(Operation & operation)
const
1030 auto ptr =
const_me()->find_ptr(operation);
1032 return std::nullopt;
1033 return std::optional<Type>(*ptr);
1043 template <
class Operation,
class T = Type>
1045 and std::copy_constructible<T>
1046 [[nodiscard]] std::optional<Type>
find_opt(Operation && operation)
const
1048 return find_opt<Operation>(operation);
1058 template <
class Operation>
1061 noexcept(const_search_is_noexcept<Operation>())
1072 template <
class T = Type>
1073 requires requires(
const T & a,
const T & b) { { a == b } -> std::convertible_to<bool>; }
1098template <
class Container,
typename T>
1132 l.
for_each([&c] (
const T & item) { c.append(item); });
1148 requires (not std::is_arithmetic_v<It>
1149 and
requires(
It it) { *it; ++it; it != it; })
1154 for (
It it = b; it != e; ++it)
1170 for (
const auto & item :
l)
1184 if constexpr (
requires (
Container & c) { c.empty(); })
1185 static_cast<Container *
>(
this)->empty();
1198 template <
class Fill>
1201 if constexpr (std::is_default_constructible_v<Container> and
1233template <
class Container,
typename T>
1243 return static_cast<const Container *
>(
this);
1247 template <
class Operation>
1250 return const_me()->traverse(operation);
1257 template <
class Arg>
1258 using Item_Arg = std::conditional_t<std::is_same_v<std::remove_cvref_t<Arg>, T>, Arg, T>;
1260 template <
class Arg>
1263 if constexpr (std::is_same_v<std::remove_cvref_t<Arg>, T>)
1264 return std::forward<Arg>(arg);
1266 return static_cast<T
>(std::forward<Arg>(arg));
1270 template <
typename... Args>
1271 requires std::constructible_from<T, Args...>
1273 { c.append(std::move(x)); }
1294 T item(std::forward<Args>(args)...);
1295 (void)
me()->append(std::move(item));
1298 template <
typename... Args>
1299 requires std::constructible_from<T, Args...>
1301 { c.append(std::move(x)); }
1305 T item(std::forward<Args>(args)...);
1306 (void)
me()->append(std::move(item));
1325 template <
typename... Args>
1326 requires std::constructible_from<T, Args...>
1328 { c.insert(std::move(x)); }
1331 T item(std::forward<Args>(args)...);
1332 (void)
me()->insert(std::move(item));
1349 template <
typename... Args>
1350 requires ((std::convertible_to<Args &&, T>
and ...)
1352 Item_Arg<Args>>
and ...))
1356 ((n += (Aleph::functional_detail::insert_one(*
me(),
as_item(std::forward<Args>(args))) ? 1 : 0)), ...);
1375 template <
typename... Args>
1376 requires ((std::convertible_to<Args &&, T>
and ...)
1378 Item_Arg<Args>>
and ...))
1382 ((n += (Aleph::functional_detail::append_one(*
me(),
as_item(std::forward<Args>(args))) ? 1 : 0)), ...);
1419 template <
typename... Items>
1420 requires ((std::convertible_to<Items &&, T>
and ...)
1422 Item_Arg<Items>>
and ...))
1425 return build_as<Container>(std::forward<Items>(items)...);
1442 template <
class D,
typename... Items>
1443 requires (std::derived_from<D, typename Aleph::concepts_detail::defer<Container, D>::type>
1444 and std::default_initializable<D>
1445 and (std::convertible_to<Items &&, T>
and ...)
1447 Item_Arg<Items>>
and ...))
1452 ((void) c.append(
as_item(std::forward<Items>(items))), ...);
1473 template <
class Operation>
1479 std::invoke(operation, item);
1494 template <
class Operation>
1498 for_each<Operation>(operation);
1505 template <
class Operation>
1507 void each(Operation & operation)
const
1522 template <
class Operation>
1524 void each(Operation && operation)
const
1526 for_each<Operation>(operation);
1543 template <
class Operation>
1545 void each(
const size_t pos,
const size_t slice, Operation & operation)
const
1555 std::invoke(operation, item);
1556 if (std::numeric_limits<size_t>::max() - next < slice)
1564 template <
class Operation>
1566 void each(
const size_t pos,
const size_t slice, Operation && operation)
const
1568 each<Operation>(pos, slice, operation);
1586 template <
class Operation>
1590 void each(
const size_t pos,
const size_t slice, Operation & operation)
1596 me()->traverse([&i, &next, slice, &operation] (T & item)
1600 std::invoke(operation, item);
1601 if (std::numeric_limits<size_t>::max() - next < slice)
1609 template <
class Operation>
1613 void each(
const size_t pos,
const size_t slice, Operation && operation)
1615 each<Operation>(pos, slice, operation);
1629 template <
class Operation>
1635 me()->traverse([&operation] (T & item)
1637 std::invoke(operation, item);
1643 template <
class Operation>
1649 mutable_for_each<Operation>(operation);
1664 template <
class Operation>
1666 [[nodiscard]]
bool all(Operation & operation)
const
1670 return static_cast<bool>(std::invoke(operation, item));
1685 template <
class Operation>
1687 [[nodiscard]]
bool all(Operation && operation)
const
1689 return all<Operation>(operation);
1705 template <
class Operation>
1707 [[nodiscard]]
bool exists(Operation & op)
const
1711 return not std::invoke(op, item);
1726 template <
class Operation>
1728 [[nodiscard]]
bool exists(Operation && op)
const
1730 return exists<Operation>(op);
1744 template <
class Operation>
1746 [[nodiscard]]
bool none(Operation & op)
const
1756 template <
class Operation>
1758 [[nodiscard]]
bool none(Operation && op)
const
1760 return none<Operation>(op);
1770 template <
class Operation>
1777 if (std::invoke(op, item))
1789 template <
class Operation>
1793 return count_if<Operation>(op);
1823 template <
typename R =
void,
class Operation>
1826 Operation & op,
const T & item)
1827 {
l.
append(std::invoke(op, item)); }
1834 ret_val.
append(std::invoke(op, item));
1853 template <
typename R =
void,
class Operation>
1856 Operation & op,
const T & item)
1857 {
l.
append(std::invoke(op, item)); }
1861 return maps<R, Operation>(op);
1882 template <
typename R =
void,
class Prop,
class Operation>
1886 Operation & op,
const T & item)
1887 {
l.
append(std::invoke(op, item)); }
1894 if (std::invoke(prop, item))
1895 ret_val.
append(std::invoke(op, item));
1916 template <
typename R =
void,
class Prop,
class Operation>
1920 Operation & op,
const T & item)
1921 {
l.
append(std::invoke(op, item)); }
1925 return maps_if<R, Prop, Operation>(prop, op);
1940 template <
typename R =
void,
class Operation>
1943 Operation & op,
const T & item)
1944 {
l.
append(std::invoke(op, item)); }
1948 return maps<R, Operation>(op);
1961 template <
typename R =
void,
class Operation>
1964 Operation & op,
const T & item)
1965 {
l.
append(std::invoke(op, item)); }
1969 return maps<R, Operation>(op);
1983 template <
typename R =
void,
class Prop,
class Operation>
1987 Operation & op,
const T & item)
1988 {
l.
append(std::invoke(op, item)); }
1992 return maps_if<R, Prop, Operation>(prop, op);
2007 template <
typename R =
void,
class Prop,
class Operation>
2011 Operation & op,
const T & item)
2012 {
l.
append(std::invoke(op, item)); }
2016 return maps_if<R, Prop, Operation>(prop, op);
2032 template <
class Operation>
2036 using Inner = std::decay_t<std::invoke_result_t<Operation &, const T &>>;
2041 auto && sub = std::invoke(op, item);
2042 if constexpr (
requires { sub.for_each(std::declval<
void (*)(
const R &)>()); })
2043 sub.for_each([&ret_val] (
const R & x)
2048 for (
auto && x : sub)
2060 template <
class Operation>
2064 return flat_map<Operation>(op);
2091 if constexpr (
requires {
const_me()->size(); })
2095 ret.push_back(item);
2143 template <
typename Acc = T,
class Op>
2145 [[nodiscard]] Acc
foldl(
const Acc & init, Op & op)
const
2169 template <
typename Acc = T,
class Op>
2171 [[nodiscard]] Acc
foldl(
const Acc & init, Op && op)
const
2173 return foldl<Acc, Op>(init, op);
2184 template <
typename Acc = T,
class Op>
2186 [[nodiscard]] Acc
fold_left(
const Acc & init, Op & op)
const
2188 return foldl<Acc, Op>(init, op);
2204 template <
typename Acc = T,
class Op>
2206 [[nodiscard]] Acc
fold_left(
const Acc & init, Op && op)
const
2208 return foldl<Acc, Op>(init, op);
2220 template <
class Operation>
2222 [[nodiscard]] T
fold(
const T & init, Operation & operation)
const
2224 return foldl<T, Operation>(init, operation);
2239 template <
class Operation>
2241 [[nodiscard]] T
fold(
const T & init, Operation && operation)
const
2243 return foldl<T, Operation>(init, operation);
2261 template <
typename Acc = T,
class Op>
2263 [[nodiscard]] Acc
foldr(
const Acc & init, Op & op)
const
2268 reversed.insert(&item);
2272 reversed.for_each([&acc, &op] (
const T * item)
2285 template <
typename Acc = T,
class Op>
2287 [[nodiscard]] Acc
foldr(
const Acc & init, Op && op)
const
2289 return foldr<Acc, Op>(init, op);
2303 template <
class Op,
class U = T>
2305 [[nodiscard]] std::optional<T>
reduce(Op & op)
const
2307 std::optional<T> acc;
2310 if (not acc.has_value())
2324 template <
class Op,
class U = T>
2326 [[nodiscard]] std::optional<T>
reduce(Op && op)
const
2328 return reduce<Op>(op);
2354 template <
class Operation>
2361 if (std::invoke(operation, item))
2379 template <
class Operation>
2383 return filter<Operation>(operation);
2409 template <
class Operation>
2416 if (std::invoke(operation, item))
2434 template <
class Operation>
2438 return ptr_filter<Operation>(operation);
2461 template <
class Operation>
2465 using TT = std::tuple<T, size_t>;
2470 if (std::invoke(operation, item))
2489 template <
class Operation>
2493 return pfilter<Operation>(operation);
2513 template <
class Operation>
2520 if (std::invoke(op, item))
2521 ret_val.first.append(item);
2523 ret_val.second.append(item);
2540 template <
class Operation>
2544 return partition<Operation>(op);
2564 ret_val.first.append(item);
2566 ret_val.second.append(item);
2586 ret_val.first.append(item);
2588 ret_val.second.append(item);
2608 template <
class Operation>
2615 if (std::invoke(op, item))
2621 return std::tuple<Aleph::DynList<T>,
Aleph::DynList<T>>(std::move(r1), std::move(r2));
2635 template <
class Operation>
2639 return tpartition<Operation>(op);
2655 noexcept(
Aleph::dry_detail::const_traversal_is_noexcept<
Container, T>)
2729 if (step == 0 or i > j)
2780 template <
class Operation>
2787 if (not std::invoke(op, item))
2800 template <
class Operation>
2804 return take_while<Operation>(op);
2816 template <
class Operation>
2821 bool dropping =
true;
2824 if (dropping
and std::invoke(op, item))
2839 template <
class Operation>
2843 return drop_while<Operation>(op);
2861 template <
class C = Container>
2862 requires requires (C & c) { c.remove(); }
2865 for (
size_t i = 0; i < n; ++i)
2881# define Derived_Build(Name) \
2882 template <typename... Items> \
2883 requires requires (Items &&... items) \
2884 { Name::template build_as<Name>(std::forward<Items>(items)...); } \
2885 [[nodiscard]] static Name build(Items &&... items) \
2887 return Name::template build_as<Name>(std::forward<Items>(items)...); \
2894template <
class Container,
typename T>
2906 return static_cast<const Container *
>(
this)->Container::template maps<T>([] (
const T & key) ->
const T &
2926template <
class Container,
typename T>
2943template <
class Container>
2948 return static_cast<const Container *
>(
this);
3024template <
class Container>
3029 return static_cast<const Container *
>(
this);
3051 template <
class C = Container>
3062 return const_me()->all([&
r] (
const typename C::Key_Type &
k)
3064 return r.search(
k) !=
nullptr;
3080 template <
class C = Container>
3093 template <
class C = Container>
3113template <
class Container>
3118 return static_cast<const Container *
>(
this);
3146 if (
cmp(a, b) or
cmp(b, a))
3188template <
class Container,
typename Key,
typename Data>
3193 return static_cast<const Container *
>(
this);
3219 const_me()->for_each([&ret_val] (
const std::pair<Key, Data> & p)
3221 ret_val.append(p.first);
3243 const_me()->for_each([&ret_val] (
const std::pair<Key, Data> & p)
3245 ret_val.append(p.second);
3271 me()->traverse([&ret_val] (std::pair<Key, Data> & p)
3273 ret_val.append(&p.second);
3287 C<const Data *> ret_val;
3288 const_me()->for_each([&ret_val] (
const std::pair<Key, Data> & p)
3290 ret_val.append(&p.second);
3305 [[nodiscard]] C<std::pair<Key, Data>>
items()
const
3307 C<std::pair<Key, Data>> ret;
3308 const_me()->for_each([&ret] (
const std::pair<Key, Data> & p)
3332 C<std::pair<Key, Data *>> ret_val;
3333 me()->traverse([&ret_val] (std::pair<Key, Data> & p)
3335 ret_val.append(std::pair<Key, Data *>(p.first, &p.second));
3347 [[nodiscard]] C<std::pair<Key, const Data *>>
items_ptr()
const
3349 C<std::pair<Key, const Data *>> ret_val;
3350 const_me()->for_each([&ret_val] (
const std::pair<Key, Data> & p)
3352 ret_val.append(std::pair<Key, const Data *>(p.first, &p.second));
3369 return me()->find(key);
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
bool traverse(const Container &c, Operation &op) noexcept(noexcept(c.traverse(op)))
Invoke c.traverse(op) as a free function (lvalue operation).
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.
STL-compatible iterator adapters for Aleph containers.
Functional programming utilities for Aleph-w containers.
Read-only view of an Aleph iterator: the iterator of a constant container.
auto has_curr() const noexcept(noexcept(std::declval< I & >().has_curr())) -> decltype(std::declval< I & >().has_curr())
true if there is a current item.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
T & insert(const T &item)
Mixin providing equality comparison for sequence containers.
friend bool operator!=(const Container &l, const Container &r)
Inequality operator.
friend bool operator==(const Container &l, const Container &r)
Equality operator.
bool equal_to(const Container &r) const
Equality test between this and r.
const Container * const_me() const noexcept
Equality test for containers sorted by a comparator.
friend bool operator!=(const Container &l, const Container &r)
Inequality operator.
const Container * const_me() const noexcept
bool equal_to(const Container &r) const
Equality test between this and r.
friend bool operator==(const Container &l, const Container &r)
Equality operator.
const Container * const_me() const noexcept
friend bool operator==(const Container &l, const Container &r)
Equality operator: l.equal_to(r).
bool equal_to(const Container &r) const
Test if elements of this are exactly contained in another container.
friend bool operator!=(const Container &l, const Container &r)
Negation of equal_to()
Common methods to the Aleph-w ( ) containers.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition(Operation &op) const
Exclusive partition of container according to a filter criterion.
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void each(const size_t pos, const size_t slice, Operation &operation)
Traverse the container starting at pos taking one item every slice, performing an operation that may ...
void emplace(Args &&... args)
Appends a new element into the container by constructing it from the given args.
Acc foldr(const Acc &init, Op &op) const
Fold the elements from the last to the first.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps(Operation &op) const
and
Insert a new element into the container by constructing it from the given args.
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void mutable_for_each(Operation &&operation)
See mutable_for_each(Operation & operation).
std::vector< T > to_vector() const
Convert container to std::vector.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map(Operation &op) const
size_t length() const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, T >)
Count the number of elements of a container.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition(size_t n) const
Exclusive partition of container in the nth item.
bool exists(Operation &op) const
Test for existence in the container of an element satisfying a criterion.
void each(Operation &operation) const
Alias of for_each().
Aleph::DynList< std::tuple< T, size_t > > pfilter(Operation &&operation) const
Overload of pfilter() that accepts rvalues.
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void mutable_for_each(Operation &operation)
Apply a mutable operation to each element of the container.
Aleph::DynList< T > to_dynlist() const
Convert container to DynList.
Aleph::DynList< std::tuple< T, size_t > > pfilter(Operation &operation) const
Filter the elements of a container according to a matching criterion and determine its positions resp...
and std::copy_constructible< U > std::optional< T > reduce(Op &op) const
Fold the elements with no initial value.
T fold(const T &init, Operation &operation) const
Simplified version of foldl() where the folded type is the same type of elements stored in the contai...
std::conditional_t< std::is_same_v< std::remove_cvref_t< Arg >, T >, Arg, T > Item_Arg
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps(Operation &&op) const
bool none(Operation &&op) const
Overload of none() that accepts rvalues.
and std::copy_constructible< U > std::optional< T > reduce(Op &&op) const
Overload of reduce() that accepts rvalues.
void each(Operation &&operation) const
Alias of for_each() that accepts rvalues.
Aleph::DynList< T > filter(Operation &operation) const
Filter the elements of a container according to a matching criterion.
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition(Operation &op) const
Exclusive partition of container according to a filter criterion.
auto flat_map(Operation &&op) const
Overload of flat_map() that accepts rvalues.
Aleph::DynList< const T * > ptr_filter(Operation &&operation) const
Overload of ptr_filter() that accepts rvalues.
Aleph::DynList< T > take_while(Operation &&op) const
Overload of take_while() that accepts rvalues.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if(Prop prop, Operation &op) const
bool all(Operation &operation) const
Check if all the elements of the container satisfy a condition.
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, T > void each(const size_t pos, const size_t slice, Operation &&operation)
See each(size_t pos, size_t slice, Operation & operation).
void emplace_end(Args &&... args)
See emplace(Args && ... args).
void each(const size_t pos, const size_t slice, Operation &&operation) const
See each(size_t pos, size_t slice, Operation & operation) const.
Aleph::DynList< T > take(const size_t n) const
Return a list with the first n elements seen in the container during its traversal.
void each(const size_t pos, const size_t slice, Operation &operation) const
Traverse the container starting at pos taking one item every slice, performing an operation on each v...
Acc foldl(const Acc &init, Op &&op) const
Overload of foldl() that accepts rvalues.
Acc foldr(const Acc &init, Op &&op) const
Overload of foldr() that accepts rvalues.
size_t nappend(Args &&... args)
Append n variadic items.
Acc foldl(const Acc &init, Op &op) const
Fold the elements of the container to a specific result.
Aleph::DynList< T > drop_while(Operation &op) const
The elements after the longest prefix that satisfies a criterion.
const Container * const_me() const noexcept
Aleph::DynList< T > rev() const
Return a list with the elements of container in reverse order respect to its traversal order.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition(Operation &&op) const
Overload of partition() that accepts rvalues.
bool exists(Operation &&op) const
Overload of exists() that accepts rvalues.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map(Operation &&op) const
Aleph::DynList< T > take_while(Operation &op) const
The longest prefix of elements that satisfy a criterion.
Container * me() noexcept
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if(Prop prop, Operation &op) const
auto flat_map(Operation &op) const
Map each element to a container and concatenate the results.
bool none(Operation &op) const
Test that no element satisfies a criterion.
size_t ninsert(Args &&... args)
Insert n variadic items.
static Container build(Items &&... items)
Build a container that holds the given items.
void for_each(Operation &&operation) const
Overload of for_each() that accepts rvalues.
void for_each(Operation &operation) const
Traverse all the container and performs an operation on each element.
Aleph::DynList< T > drop_while(Operation &&op) const
Overload of drop_while() that accepts rvalues.
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > maps_if(Prop prop, Operation &&op) const
T fold(const T &init, Operation &&operation) const
Overload of fold() that accepts rvalues.
size_t count_if(Operation &op) const
Count the elements that satisfy a criterion.
bool all(Operation &&operation) const
Overload of all() that accepts rvalues.
size_t count_if(Operation &&op) const
Overload of count_if() that accepts rvalues.
Acc fold_left(const Acc &init, Op &op) const
Alias for foldl().
Aleph::DynList< Aleph::dry_detail::map_result_t< R, Operation &, T > > map_if(Prop prop, Operation &&op) const
Aleph::DynList< T > filter(Operation &&operation) const
Overload of filter() that accepts rvalues.
bool const_traverse(Operation &&operation) const
Aleph::DynList< T > take(size_t i, const size_t j, const size_t step=1) const
Return a list with the elements at positions i, i + step, i + 2 step, ... that are not greater than j...
Acc fold_left(const Acc &init, Op &&op) const
Overload of fold_left() that accepts rvalues.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > split_half() const
Split the container into two halves by alternating elements.
static D build_as(Items &&... items)
Build a D, a class derived from the container, holding the given items.
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition(Operation &&op) const
Overload of tpartition() that accepts rvalues.
Aleph::DynList< T > drop(const size_t n) const
Drop the first n elements seen in the container during its traversal.
void emplace_ins(Args &&... args)
Aleph::DynList< const T * > ptr_filter(Operation &operation) const
Filter the elements of a container according to a matching criterion and return a pointer to the matc...
void mutable_drop(const size_t n)
Drop the first n elements seen from container.
static decltype(auto) as_item(Arg &&arg)
Common sequential searching methods on containers.
const Type * find_ptr(Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
Overload of find_ptr() const that accepts rvalues.
size_t find_index(Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
Overload of find_index() that accepts rvalues.
Type & nth(const size_t n)
Return the n-th item of the container.
auto get_itor()
Alias of get_it().
static constexpr bool const_search_is_noexcept() noexcept
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * find_ptr(Operation &&operation) noexcept(mutable_search_is_noexcept< Operation >())
Overload of find_ptr() that accepts rvalues.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
auto get_itor() const
See get_itor().
Container * me() noexcept
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > find_item(Operation &&operation) const noexcept(find_item_is_noexcept< Operation >())
Overload of find_item() that accepts rvalues.
const Type * const_nth_ptr(const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, Type >)
and std::copy_constructible< T > std::optional< Type > find_opt(Operation &operation) const
Copy of the first item satisfying a criterion, if any.
and Aleph::dry_detail::MutablyTraversable< typename Aleph::concepts_detail::defer< Container, Operation >::type, Type > Type * find_ptr(Operation &operation) noexcept(mutable_search_is_noexcept< Operation >())
Find a pointer to an item in the container according to a searching criterion.
const Type & nth(const size_t n) const
Const overload of nth(size_t).
bool contains(const Type &item) const
Test if an item is present in the container using equality.
size_t find_index(Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
Find the position of an item in the container according to a searching criterion.
auto get_it(const size_t pos)
Return a properly initialized iterator positioned at the pos item on the container.
static constexpr bool find_item_is_noexcept() noexcept
True if find_item() cannot throw: neither the search nor building the returned tuple,...
const Container * const_me() const noexcept
const Type * find_ptr(Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
Const overload of find_ptr(Operation&).
Type & nth_ne(const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< C, Type >)
Return the n‑th element without bounds checking.
and std::default_initializable< T > and std::copy_constructible< T > std::tuple< bool, Type > find_item(Operation &operation) const noexcept(find_item_is_noexcept< Operation >())
Safe sequential searching of an item matching a criterion.
const Type & nth_ne(const size_t n) const noexcept(Aleph::dry_detail::const_traversal_is_noexcept< Container, Type >)
Constant overload of nth_ne(size_t).
auto get_it() const
Read-only iterator positioned at the first item.
bool contains_if(Operation &&operation) const noexcept(const_search_is_noexcept< Operation >())
Test if an item satisfying a criterion is present in the container.
and std::copy_constructible< T > std::optional< Type > find_opt(Operation &&operation) const
Overload of find_opt() that accepts rvalues.
auto get_it(const size_t pos) const
Read-only iterator positioned at the pos item.
const Type * first_const_ptr(Operation &operation) const noexcept(const_search_is_noexcept< Operation >())
static constexpr bool mutable_search_is_noexcept() noexcept
Type * mutable_nth_ptr(const size_t n) noexcept(Aleph::dry_detail::mutable_traversal_is_noexcept< Container, Type >)
Common methods to mapping containers.
C< Key > keys() const
Return the domain set of container.
C< std::pair< Key, const Data * > > items_ptr() const
Constant overload of items_ptr().
C< Data * > values_ptr()
Return a container of pointers to the elements of range set of container.
C< std::pair< Key, Data * > > items_ptr()
Return a container with the entire mapping where the range could be modified.
C< const Data * > values_ptr() const
Constant overload of values_ptr().
C< Data > values() const
Return the range set of container.
Container * me() noexcept
C< std::pair< Key, Data > > items() const
Return a container with the entire mapping.
const Container * const_me() const noexcept
Data & operator()(const Key &key)
Return the image or element mapped to key.
A container whose append() accepts an argument of type Item.
A container whose insert() accepts an argument of type Item.
std::invoke(f, args...) is valid and usable as a condition.
std::invoke(f, args...) is valid.
PredicateWith<F, Args...>, and neither the call nor the conversion of its result to bool can throw.
f(args...) is a valid call whose result is usable as a condition.
op folds an accumulator Acc with an item T.
op folds an item T with an accumulator Acc from the right.
The modifiable traversal of Container hands out T &.
Container can be compared as a set: it has size(), a Key_Type and a search() that returns a pointer.
void swap(__gmp_expr< T, T > &x, __gmp_expr< T, T > &y) noexcept
Exchange two numbers of the same class without allocating.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
typename std::conditional_t< std::is_void_v< R >, decayed_invoke_result< Op, T >, std::type_identity< R > >::type map_result_t
Item type of a mapping: R, or the decayed type that Op returns when R is void.
void advance(It &it) noexcept(advance_is_noexcept< It >)
Advance an iterator that is positioned on an item.
decltype(auto) current(It &it) noexcept(current_is_noexcept< It >)
Current item of an iterator that is positioned on one.
constexpr bool current_is_noexcept
Reading the current item of an iterator positioned on one cannot throw.
void assign_fold(Acc &acc, Step &&step)
Store in acc the result of a folding step step().
constexpr bool const_traversal_is_noexcept
The constant traversal of Container cannot throw by itself.
void fold_left_step(Acc &acc, Op &op, const T &item)
One step of a left fold: acc = op(acc, item).
void fold_right_step(Acc &acc, Op &op, const T &item)
One step of a right fold: acc = op(item, acc).
constexpr bool advance_is_noexcept
Advancing an iterator positioned on an item cannot throw.
constexpr bool mutable_traversal_is_noexcept
The modifiable traversal of Container cannot throw by itself.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
void next()
Advance all underlying iterators (bounds-checked).
auto iterator_for(C &c)
Iterator on c positioned on its first item: the container's own iterator on a modifiable container.
T itself, made dependent on Deferred.
decltype(std::declval< typename defer< Container, Deferred >::type::Iterator & >().get_curr()) type
const std::remove_reference_t< typename traverse_arg< Container, Deferred >::type > & type
Operation that needs to modify the item it receives.
bool operator()(T &item) const noexcept
Declared only; never called.
Operation that only reads the item and never throws.
bool operator()(const T &item) const noexcept
Declared only; never called.
typename C::Item_Type type
Item type of a container returned by the operation of flat_map(): its Item_Type, or else its value_ty...
typename C::value_type type
Generic list of items stored in a container.
Aleph::DynList< T > items() const
Return a list of all the elements of a container sorted by traversal order.
Aleph::DynList< T > keys() const
See items().
Generic traversal of the container through its iterator.
bool traverse(Operation &&operation) noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_arg< Container, Operation >::type, Container & >())
Overload of traverse(Operation &) that accepts rvalues.
static constexpr bool traverse_is_noexcept() noexcept
std::conditional_t< std::is_constructible_v< typename Aleph::concepts_detail::defer< Container, Deferred >::type::Iterator, const typename Aleph::concepts_detail::defer< Container, Deferred >::type & >, const typename Aleph::concepts_detail::defer< Container, Deferred >::type &, typename Aleph::concepts_detail::defer< Container, Deferred >::type & > const_source_t
bool traverse(Operation &operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Container, Operation >::type, const_source_t< Operation > >())
Traverse a constant container; each item is handed out as a constant reference.
bool traverse(Operation &&operation) const noexcept(traverse_is_noexcept< Operation, typename Aleph::concepts_detail::traverse_carg< Container, Operation >::type, const_source_t< Operation > >())
Overload of traverse(Operation &) const that accepts rvalues.
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.
Special constructors common to Aleph-w ( ) containers.
SpecialCtors(const SpecialCtors &)=default
Copy constructor; the derived container copies its items.
SpecialCtors(SpecialCtors &&) noexcept
Move constructor; the derived container moves its items.
SpecialCtors(std::initializer_list< T > l)
Construct the container from an initializer list.
SpecialCtors(It b, It e)
Construct the container from a range of iterators.
void build_apart(Fill fill)
Fill the container: in another one built apart, whose items it takes with swap(), if the container ha...
SpecialCtors(const Aleph::DynList< T > &l)
Build the container by inserting all items of the list l.
SpecialCtors()=default
Default constructor; it appends nothing.
void free_appended() noexcept
Free the items that a constructor of this base appended.
SpecialCtors & operator=(const SpecialCtors &)=default
Copy assignment; the derived container copies its items.
Filter_Iterator< DynList< int >, DynList< int >::Iterator, Par > It