63template <
class Container>
67 template <
class Operation>
70 return noexcept(std::declval<Operation&>()(
71 std::declval<typename Container::Item_Type&>()));
94 template <
class Operation>
95 bool traverse(Operation & operation)
noexcept(traverse_is_noexcept<Operation>())
97 for (
typename Container::Iterator it(*
static_cast<Container*
>(
this));
98 it.has_curr(); it.next())
99 if (not operation(it.get_curr()))
105 template <
class Operation>
106 bool traverse(Operation & operation)
const noexcept(traverse_is_noexcept<Operation>())
108 return const_cast<GenericTraverse*
>(
this)->traverse<Operation>(operation);
112 template <
class Operation>
113 bool traverse(Operation && operation)
const noexcept(traverse_is_noexcept<Operation>())
115 return traverse<Operation>(operation);
119 template <
class Operation>
120 bool traverse(Operation && operation)
noexcept(traverse_is_noexcept<Operation>())
122 return traverse<Operation>(operation);
126template <
class Container,
class Operation>
128 noexcept(
noexcept(c.traverse(op)))
130 return c.traverse(op);
133template <
class Container,
class Operation>
135 noexcept(
noexcept(c.traverse(std::forward<Operation>(op))))
137 return c.traverse(std::forward<Operation>(op));
162template <
class Container,
typename Type>
169 return static_cast<const Container*
>(
this);
177 template <
class Operation>
180 return noexcept(std::declval<Operation&>()(std::declval<Type&>()));
192 return typename Container::Iterator(*
const_me());
208 auto ret =
typename Container::Iterator(*
const_me());
209 for (
size_t i = 0; i < pos; ++i)
228 Type * ptr =
nullptr;
230 me()->traverse([&ptr, &i, &n] (Type & item)
246 const Type &
nth_ne(
const size_t n)
const noexcept
248 return base()->nth_ne(n);
267 Type &
nth(
const size_t n)
269 Type * ptr =
nullptr;
271 me()->traverse([&ptr, &i, &n] (Type & item)
290 const Type &
nth(
const size_t n)
const
292 return base()->nth(n);
317 template <
class Operation>
319 noexcept(operation_is_noexcept<Operation>())
321 Type * ptr =
nullptr;
322 me()->traverse([&ptr,&operation] (Type & item)
339 template <
class Operation>
341 noexcept(operation_is_noexcept<Operation>())
343 return base()->find_ptr(operation);
351 template <
class Operation>
352 const Type *
find_ptr(Operation && operation)
const
353 noexcept(operation_is_noexcept<Operation>())
355 return find_ptr<Operation>(operation);
363 template <
class Operation>
365 noexcept(operation_is_noexcept<Operation>())
367 return find_ptr<Operation>(operation);
392 template <
class Operation>
394 noexcept(operation_is_noexcept<Operation>())
397 const_me()->traverse([&i,&operation] (Type & item)
412 template <
class Operation>
414 noexcept(operation_is_noexcept<Operation>())
416 return find_index<Operation>(operation);
439 template <
class Operation>
441 noexcept(operation_is_noexcept<Operation>())
443 using TT = std::tuple<bool, Type>;
445 return ptr ?
TT(
true, *ptr) :
TT(
false, Type());
449 template <
class Operation>
450 std::tuple<bool, Type>
find_item(Operation & operation)
const
451 noexcept(operation_is_noexcept<Operation>())
453 using TT = std::tuple<bool, Type>;
455 return ptr ?
TT(
true, *ptr) :
TT(
false, Type());
459 template <
class Operation>
460 std::tuple<bool, Type>
find_item(Operation && operation)
461 noexcept(operation_is_noexcept<Operation>())
463 return find_item<Operation>(operation);
467 template <
class Operation>
468 std::tuple<bool, Type>
find_item(Operation && operation)
const
469 noexcept(operation_is_noexcept<Operation>())
471 return find_item<Operation>(operation);
490template <
class Container,
typename T>
511 static_cast<Container*
>(
this)->append(item);
523 for (It it = b; it != e; ++it)
524 static_cast<Container*
>(
this)->append(*it);
533 for (
const auto & item :
l)
534 static_cast<Container*
>(
this)->append(item);
546template <
class Container,
typename T>
558 return static_cast<const Container*
>(
this);
581 template <
typename ...Args>
584 (
void)
me()->append(T(std::forward<Args>(
args)...));
588 template <
typename ...Args>
591 (
void)
me()->append(T(std::forward<Args>(
args)...));
612 template <
typename ...Args>
615 (
void)
me()->insert(T(std::forward<Args>(
args)...));
623 template <
typename ...
Args>
626 (
void)
me()->insert(item);
631 template <
typename ...
Args>
634 (
void)
me()->append(item);
646 template <
typename ...
Args>
659 template <
typename ...
Args>
684 template <
class Operation>
695 template <
class Operation>
702 template <
class Operation>
709 template <
class Operation>
716 template <
class Operation>
723 template <
class Operation>
730 template <
class Operation>
737 template <
class Operation>
763 template <
class Operation>
773 if (
not it.has_curr())
780 template <
class Operation>
786 template <
class Operation>
797 template <
class Operation>
815 template <
class Operation>
826 template <
class Operation>
845 template <
class Operation>
849 traverse([&op] (
const T & i) {
return not op(i); });
857 template <
class Operation>
903 template <
typename __T = T,
class Operation = Aleph::Dft_Map_Op<T, __T>>
920 template <
typename __T = T,
class Operation = Aleph::Dft_Map_Op<__T, __T>>
939 template <
typename __T = T,
class Prop,
class Operation>
958 template <
typename __T = T,
class Prop,
class Operation>
970 return maps([] (
auto & item) {
return item; });
980 if constexpr (
requires {
const_me()->size(); })
982 const_me()->for_each([&
ret] (
const T & item) {
ret.push_back(item); });
1033 template <
typename __T = T,
class Op = Aleph::Dft_Fold_Op<__T, T>>
1051 template <
typename __T = T,
class Op = Aleph::Dft_Fold_Op<__T, T>>
1064 template <
typename __T = T,
class Op = Aleph::Dft_Fold_Op<__T, T>>
1077 template <
typename __T = T,
class Op = Aleph::Dft_Fold_Op<__T, T>>
1088 template <
class Operation>
1105 template <
class Operation>
1134 template <
class Operation>
1151 template <
class Operation>
1180 template <
class Operation>
1197 template <
class Operation>
1222 template <
class Operation>
1225 using TT = std::tuple<T, size_t>;
1242 template <
class Operation>
1265 template <
class Operation>
1284 template <
class Operation>
1300 template <
class Operation>
1349 template <
class Operation>
1353 const_me()->for_each([&
r1, &r2, &op] (
const T & item)
1368 template <
class Operation>
1388 const_me()->for_each([&count] (
const T &) { ++count; });
1422 const_me()->traverse([&i, &
ret, n] (
const T & item)
1449 for (
auto it =
const_me()->get_it(i); i <= j
and it.has_curr();
1450 it.next_ne(), i +=
step)
1471 const_me()->traverse([&i, &
ret, n] (
const T & item)
1490 for (
size_t i = 0; i < n; ++i)
1499template <
class Container,
typename T>
1511 return static_cast<const Container*
>(
this)->
1512 Container::template maps<T> ([] (
const T & key) {
return key; });
1524template <
class Container,
typename T>
1532template <
class Container>
1537 return static_cast<const Container*
>(
this);
1565 if (
const_me()->size() != r.size())
1568 return const_me()->all([&r] (
const typename Container::Key_Type & k)
1569 {
return r.search(k) !=
nullptr; });
1589template <
class Container,
typename Key,
typename Data>
1594 return static_cast<const Container*
>(
this);
1616 const_me()->for_each([&ret_val] (
const Key & p)
1618 ret_val.append(p.first);
1640 const_me()->for_each([&ret_val] (
const std::pair<Key, Data> & p)
1642 ret_val.append(p.second);
1666 const_me()->for_each([&ret_val] (std::pair<Key, Data> & p)
1667 { ret_val.append(&p.second); });
1683 C<std::pair<Key, Data>> ret;
1684 const_me()->for_each([&ret] (std::pair<Key, Data> & p) { ret.append(p); });
1703 const_me()->for_each([&ret_val] (std::pair<Key, Data> & p)
1705 ret_val.append(std::pair<Key,Data*>(p.first,
1718 return this->find(key);
1728 return this->find(key);
bool traverse(const Container &c, Operation &op) noexcept(noexcept(c.traverse(op)))
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.
Functional programming utilities for Aleph-w containers.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Append a new item by copy.
Equality test for containers.
const Container * const_me() const
bool operator!=(const Container &r) const noexcept
Negation of equal_to()
bool operator==(const Container &r) const noexcept
bool equal_to(const Container &r) const noexcept
Test if elements of this are exactly contained in another container.
Common methods to the Aleph-w ( ) containers.
void mutable_for_each(Operation &operation)
Aleph::DynList< std::tuple< T, size_t > > pfilter(Operation &&operation) const
Overload of pfilter(Operation&) that accepts rvalues.
void each(Operation &operation)
Alias of for_each(Operation&).
__T foldl(const __T &init, Op &op) const
Fold the elements of the container to a specific result.
Aleph::DynList< T > filter(Operation &operation) const
Filter the elements of a container according to a matching criteria.
Aleph::DynList< __T > maps(Operation &&op) const
Overload of maps(Operation&) that accepts rvalues.
std::vector< T > to_vector() const
Convert container to std::vector.
Aleph::DynList< T > filter(Operation &&operation) const
Overload of filter(Operation&) that accepts rvalues.
__T foldl(const __T &init, Op &&op=Op()) const
Overload of foldl(const __T&, Op&) that accepts rvalues.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition(size_t n) const
Exclusive partition of container in the nth item.
Aleph::DynList< T > to_dynlist() const
Convert container to DynList.
void emplace(Args &&... args)
Appends a new element into the container by constructing it in-place with the given args.
void each(Operation &operation) const
Const alias of for_each(Operation&).
size_t ninsert(Args ... args)
Insert n variadic items.
__T fold_left(const __T &init, Op &&op=Op()) const
Overload of fold_left(const __T&, Op&) that accepts rvalues.
Aleph::DynList< __T > maps_if(Prop prop, Operation &op) const
Conditional mapping of the elements of the container.
FunctionalMethods< Container, T > * base() const noexcept
Aleph::DynList< const T * > ptr_filter(Operation &&operation) const
Overload of ptr_filter(Operation&) that accepts rvalues.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition(Operation &op) const
Exclusive partition of container according to a filter criteria.
void each(const size_t pos, const size_t slice, Operation &&operation) const
void emplace_ins(Args &&... args)
Insert a new element into the container by constructing it in-place with the given args.
void mutable_for_each(Operation &&operation)
Aleph::DynList< T > take(const size_t n) const
Return a list with the first n elements seen in the container during its traversal.
bool exists(Operation &op) const
Test for existence in the container of an element satisfying a criteria.
void nninsert(size_t &n, const T &item, Args &... args)
void each(Operation &&operation) const
Const alias of for_each(Operation&) that accepts rvalues.
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition(Operation &op) const
Exclusive partition of container according to a filter criteria.
const Container * const_me() const noexcept
void each(size_t pos, const size_t slice, Operation &operation) const
Traverse the container starting at pos taking one item every slice, performing a mutable operation on...
size_t nappend(Args ... args)
Append n variadic items.
bool all(Operation &operation) const
Check if all the elements of container satisfy a condition.
Aleph::DynList< T > rev() const
Return a list with the elements of container in reverse order respect to its traversal order.
void emplace_end(Args &&... args)
void nnappend(size_t &n, const T &item, Args &... args)
bool all(Operation &&operation) const
Overload of all(Operation&) that accepts rvalues.
bool exists(Operation &&op) const
Overload of exists(Operation&) that accepts rvalues.
size_t length() const noexcept
Count the number of elements of a container.
void for_each(Operation &&operation) const
Overload of for_each(Operation&) const that accepts rvalues.
Aleph::DynList< __T > maps_if(Prop prop, Operation &&op) const
Overload of maps_if(Prop, Operation&) that accepts rvalues.
T fold(const T &init, Operation &&operation) const
Overload of fold(const T&, Operation&) that accepts rvalues.
void mutable_drop(const size_t n)
Drop the first n elements seen from container.
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...
Aleph::DynList< std::tuple< T, size_t > > pfilter(Operation &operation) const
Filter the elements of a container according to a matching criteria and determine its positions respe...
Aleph::DynList< const T * > ptr_filter(Operation &operation) const
Filter the elements of a container according to a matching criteria and return a pointer to the match...
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
void each(Operation &&operation)
Alias of for_each(Operation&) that accepts rvalues.
Aleph::DynList< __T > maps(Operation &op) const
Map the elements of the container.
std::tuple< Aleph::DynList< T >, Aleph::DynList< T > > tpartition(Operation &&op) const
Overload of tpartition(Operation&) that accepts rvalues.
void for_each(Operation &operation) const
Const overload of for_each(Operation&).
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > partition(Operation &&op) const
Overload of partition(Operation&) that accepts rvalues.
Aleph::DynList< T > take(size_t i, const size_t j, const size_t step=1) const
Return a list with elements seen in the container between i and j position respect to its traversal.
std::pair< Aleph::DynList< T >, Aleph::DynList< T > > split_half() const
Split the container into two halves by alternating elements.
__T fold_left(const __T &init, Op &op) const
Alias for foldl with the same accumulator type.
void for_each(Operation &&operation)
Overload of for_each(Operation&) that accepts rvalues.
Aleph::DynList< T > drop(const size_t n) const
Drop the first n elements seen in the container during its traversal.
Common sequential searching methods on containers.
static constexpr bool operation_is_noexcept() noexcept
size_t find_index(Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
Overload of find_index(Operation&) that accepts rvalues.
std::tuple< bool, Type > find_item(Operation &operation) noexcept(operation_is_noexcept< Operation >())
Safe sequential searching of an item matching a criteria.
Type * find_ptr(Operation &operation) noexcept(operation_is_noexcept< Operation >())
Find a pointer to an item in the container according to a searching criteria.
auto get_itor() const
Alias of get_it().
size_t find_index(Operation &operation) const noexcept(operation_is_noexcept< Operation >())
Find the position of an item in the container according to a searching criteria.
Type * find_ptr(Operation &&operation) noexcept(operation_is_noexcept< Operation >())
Overload of find_ptr(Operation&) that accepts rvalues.
Container * me() noexcept
Type & nth_ne(const size_t n) noexcept
Return the n‑th element without bounds checking.
const Type * find_ptr(Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
Overload of find_ptr(Operation&) const that accepts rvalues.
LocateFunctions< Container, Type > * base() const
const Type & nth(const size_t n) const
Const overload of nth(size_t).
Type & nth(const size_t n)
Return the n-th item of container.
std::tuple< bool, Type > find_item(Operation &&operation) const noexcept(operation_is_noexcept< Operation >())
const Type * find_ptr(Operation &operation) const noexcept(operation_is_noexcept< Operation >())
Const overload of find_ptr(Operation&).
std::tuple< bool, Type > find_item(Operation &operation) const noexcept(operation_is_noexcept< Operation >())
const Container * const_me() const noexcept
std::tuple< bool, Type > find_item(Operation &&operation) noexcept(operation_is_noexcept< Operation >())
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
auto get_it(const size_t pos) const
Return a properly initialized iterator positioned at the pos item on the container.
const Type & nth_ne(const size_t n) const noexcept
Const overload of nth_ne(size_t).
Common methods to mapping containers.
C< Key > keys() const
Return the domain set of container.
C< std::pair< Key, Data * > > items_ptr() const
Return a container with the entire mapping where the range could be modified.
C< Data > values() const
Return the range set of container.
C< std::pair< Key, Data > > items() const
Return a container with the entire mapping.
Data & operator()(const Key &key)
Return the image or element mapped to key.
const Container * const_me() const
C< Data * > values_ptr() const
Return a container of pointers to the elements of range set of container.
Generic list of items stored in a container.
Aleph::DynList< T > keys() const
Aleph::DynList< T > items() const
Return a list of all the elements of a container sorted by traversal order.
Generic traversal of the container through its iterator.
bool traverse(Operation &&operation) const noexcept(traverse_is_noexcept< Operation >())
Overload of traverse(Operation&) const that accepts rvalues.
bool traverse(Operation &operation) const noexcept(traverse_is_noexcept< Operation >())
Const overload of traverse(Operation&).
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.
bool traverse(Operation &&operation) noexcept(traverse_is_noexcept< Operation >())
Overload of traverse(Operation&) that accepts rvalues.
static constexpr bool traverse_is_noexcept() noexcept
Special constructors common to Aleph-w ( ) containers.
SpecialCtors(const SpecialCtors &)=default
SpecialCtors(SpecialCtors &&) noexcept
SpecialCtors(std::initializer_list< T > l)
Construct the container from an initializer list.
SpecialCtors & operator=(const SpecialCtors &)
SpecialCtors(It b, It e)
Construct the container from a range of iterators.
SpecialCtors(const Aleph::DynList< T > &l)
Build the container by inserting all items of list l.