48# include <type_traits>
59# define NEXT(p) (p->get_next())
63template <
typename T>
class Snodenc;
190 template <
typename T>
inline
261 return curr !=
nullptr;
276 <<
"Iterator is at the end of the list";
299 <<
"Iterator is at the end of the list";
326 template <
typename T>
345 static_assert(std::is_default_constructible<T>::value,
346 "No default constructor for T");
354 static_assert(std::is_copy_constructible<T>::value,
355 "No copy constructor for T");
364 static_assert(std::is_move_constructible<T>::value,
365 "No move constructor for T");
433 template <
typename T>
inline
439 template <
typename T>
inline
748 NEXT(link) = list.head;
754 list.head = list.tail =
nullptr;
780 <<
"HTList is empty";
835 <<
"Removing from a empty list";
847 prev = p, p =
NEXT(p))
889 <<
"HTList as stack is empty";
896 <<
"HTList as stack is empty";
946 while (q !=
tail and q !=
nullptr)
949 if (q ==
tail or q ==
nullptr)
1029 list.head =
NEXT(link);
1030 list.tail = list.head ==
nullptr ?
nullptr :
tail;
1033 NEXT(link) =
nullptr;
1180 <<
"Iterator overflow";
1225 <<
"Iterator overflow";
1279 <<
"Iterator overflow";
1369 for (
size_t i = 0; i < n; ++i)
1415 template <
typename T =
int>
1426 using CtorBase::CtorBase;
1465 static_assert(std::is_copy_constructible_v<T>
or
1466 std::is_move_constructible_v<T>,
1467 "No copy assign for T");
1469 return p->get_data();
1474 static_assert(std::is_copy_constructible_v<T>
or
1475 std::is_move_constructible_v<T>,
1476 "No copy assign for T");
1478 return p->get_data();
1540 return push(std::forward<T>(item));
1600 T ret_val = std::move(p->get_data());
1615 T ret_val = std::move(p->get_data());
1757 T
ret_val = std::move(p->get_data());
1776 for (
auto it = this->
get_it(); it.has_curr(); it.next())
1784 template <
class Equal = std::equal_to<T>>
1789 const T & item = it.get_curr_ne();
1823 template <
class Equal = std::equal_to<T>>
T remove(Equal
eq)
1826 if (
const T & item = it.get_curr();
eq(item))
1987template <
class Container>
1996 template <
typename T>
inline
2004 template <
typename T>
inline
Variadic constructor macros for containers.
Container traversal and functional operation mixins.
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error()
Throws std::domain_error unconditionally.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
STL-compatible iterator adapters for Aleph containers.
Standard functor implementations and comparison objects.
Functional programming utilities for Aleph-w containers.
Iterator on the items of list.
Iterator() noexcept=default
The type of container.
T & get_curr() const
Return the current item.
T del()
Remove the current item of the iterator.
T & get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
Insert a new item by copy.
T remove(Equal eq)
Remove the first element matching an equality criteria.
T & get_last_ne() const noexcept
Return the last item of the list without exception.
T & insert(T &&item)
Insert a new item by movement.
T & append(T &&item)
Append a new item by movement.
DynList(DynList &&l) noexcept
Initialize the list with all the items of l moved to this.
T remove_ne(Equal eq) noexcept
T & append(const T &item)
Append a new item by copy.
T Item_Type
The type of item.
Slinknc * get_tail() const noexcept=delete
T Key_Type
The type of item.
DynList & operator=(const DynList &l)
Assign to this a copy of l
Slinknc * get_head() const noexcept=delete
DynList & append(DynList &&list) noexcept
Append listat the end of this by movement.
T & operator[](const size_t &i)
Array-style access to the i-th item. Equivalent to get(i).
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of the list.
T remove_ne() noexcept
Remove the first item of the list without exception.
DynList reverse() const
Return a reversed copy of this.
T remove()
Remove the first item of the list.
T & __insert(Snodenc< T > *p) noexcept
DynList(const DynList &l)
Initialize a list with a copy of all the items of list l
T & get(const size_t i)
Obtains a modifiable reference to the i-th item of this.
DynList & insert(const DynList &list)
Insert to this a copy of list.
DynList & insert(DynList &&list) noexcept
Insert listat the beginning of this by movement.
T & __append(Snodenc< T > *p) noexcept
DynList & reverse() noexcept
void empty() noexcept
empty the list
DynList()
Initialize an empty list.
DynList & swap(DynList &l) noexcept
Swap this with l.
DynList & append(const DynList &list)
Append to this a copy of list.
T remove_first_ne() noexcept
T & get_first_ne() const noexcept
Return the first item of the list without exception.
Slinknc * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
long get_pos() const noexcept
Return the current position.
void reset_last()
It has O(n) of performance.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
void reset_first() noexcept
bool is_in_last() const noexcept
Return true if the iterator is positioned on the last item.
bool is_last() const noexcept
void next()
Move the iterator one item forward.
Slinknc * get_curr() const
Return the current node on which the iterator is positioned.
Iterator & operator=(const Iterator &it) noexcept
Assignation.
bool has_curr() const noexcept
Return true if iterator has current item.
bool is_in_first() const noexcept
Return true if the iterator is positioned on the first item.
Slinknc * del_ne() noexcept
Iterator() noexcept=default
void end() noexcept
Set the iterator to its end position, which has not current item.
void reset() noexcept
Reset the iterator at the first item.
Slinknc * del()
Remove the current item.
Single linked list of nodes.
Slinknc * get_first() const noexcept
Return list first element.
void push(Slinknc *link) noexcept
Insert link as first element.
void put(Slinknc *link) noexcept
Insert link as last element.
size_t reverse_list() noexcept
void remove_all_and_delete() noexcept
Remove and free memory for all the items of list.
Slinknc * get_tail() const noexcept
Return list tail (last element)
size_t reverse() noexcept
It inverts all list elements.
void insert(HTList &l) noexcept
Insert starting in link (contained in 'this' list) the 'list' list.
void cut_list(Slinknc *link, HTList &list) noexcept
constexpr bool is_empty() const noexcept
Return true if list is empty.
void insert(Slinknc *link, HTList &list) noexcept
Insert a list into this after one of its items.
Slinknc * get_head() const noexcept
Return list head (first element)
void rotate_left(size_t n)
Rotate to left the list n positions.
void cut(Slinknc *link, HTList &list) noexcept
It cuts 'this' over 'link' element and it puts all remaining elements.
void concat_list(HTList &l) noexcept
HTList & swap(HTList &l) noexcept
Exchange 'this' values with another list.
void append(Slinknc *link) noexcept
Insert link as last element.
size_t split_list(HTList &l, HTList &r) noexcept
It divides 'this' into two equal lists without modifying elements order.
void append(HTList &l) noexcept
Join 'this' with 'l' through list end.
HTList() noexcept
Initialize an empty list.
Slinknc * remove_first_ne() noexcept
size_t split(HTList &l, HTList &r) noexcept
size_t size() const noexcept
Count the number of elements of the list.
bool remove(Slinknc *link)
Remove from the list the item pointed by link
void insert(Slinknc *link) noexcept
Insert link as first element.
Slinknc * remove_head_ne() noexcept
It deletes head element (first one).
bool is_unitarian() const noexcept
Return true if the list contains exactly just one element.
Slinknc * get_last() const noexcept
Return the last item of the list (nullptr if the list is empty)
size_t split_list_ne(HTList &l, HTList &r) noexcept
void concat(HTList &l) noexcept
Concat to 'this' all 'l' list; 'l' becomes empty.
bool is_unitarian_or_empty() const noexcept
Return true if list contains one element or is empty.
Iterator on single links.
void reset_first() noexcept
Reset the iterator to the first link on the list.
void next()
Move the iterator one position forward.
bool has_curr() const noexcept
Return true if the iterator is positioned on a valid link.
Slinknc * get_curr() const
Return the current link on which the iterator is positioned.
Slinknc * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Iterator(Slinknc *_head, Slinknc *_curr) noexcept
Initialize an iterator on the list pointed by _head, but on a node pointed by curr
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
Iterator(Slinknc &list) noexcept
Initialize an iterator on the first node of list
Link of a single linked list non-circular and without header node.
virtual ~Slinknc()=default
Slinknc *& get_next() noexcept
getter
void reset() noexcept
Reset the link to nullptr.
Slinknc() noexcept
Init to nullptr.
constexpr bool is_empty() const noexcept
Return true if this is empty.
Slinknc & operator=(const Slinknc &) noexcept
Dummy asignation; link is set to nullptr.
Slinknc(const Slinknc &) noexcept
Dummy copy constructor.
Snodenc< T > * to_snodenc() noexcept
Convert this to a Snodenc<T>.
Slinknc * remove_next() noexcept
Remove for linked list the node pointed by this
void insert(Slinknc *p) noexcept
Insert p after this
Node belonging to a single non-circular linked list without header node.
Snodenc(T &&item)
Construct by moving item
Snodenc(const T &item)
Construct with copy of item
const T & get_data() const noexcept
Return a constant reference to the data.
Snodenc *& get_next() noexcept
Return the node following to this
Snodenc *& get_first() const noexcept
Return the node following to this.
T & get_data() noexcept
Return a modifiable reference to the data.
Snodenc * remove_next() noexcept
Remove the node following to this.
Snodenc * remove_first() noexcept
Common methods to the Aleph-w ( ) containers.
Aleph::DynList< __T > maps(Operation &op) const
Map the elements of the container.
Common sequential searching methods on containers.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
Main namespace for Aleph-w library functions.
DynList< typename Container::Item_Type > to_dynlist(const Container &c)
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
std::decay_t< typename HeadC::Item_Type > T
DynList< T > unitarian_DynList(const T &item)
bool has_curr() const noexcept
Return true if all underlying iterators are positioned on a valid item.
DynList< T > get_unitarian_DynList(const T &item)
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.
Generic list of items stored in a container.
Generic traversal of the container through its iterator.
Special constructors common to Aleph-w ( ) containers.