58#define NEXT(p) (p->get_next())
102 [[nodiscard]]
constexpr bool is_empty() const noexcept
104 return next ==
nullptr;
148 assert(p !=
nullptr);
172 template <
typename T>
176 template <typename
T>
180 template <typename
T>
184 template <typename
T>
185 inline const
T &
to_data() const noexcept;
233 return curr !=
nullptr;
309 static_assert(std::is_default_constructible<T>::value,
"No default constructor for T");
316 static_assert(std::is_copy_constructible<T>::value,
"No copy constructor for T");
323 static_assert(std::is_move_constructible<T>::value,
"No move constructor for T");
384 return this->to_snodenc<T>()->
get_data();
390 return this->to_snodenc<T>()->get_data();
434 [[nodiscard]]
constexpr bool is_empty() const noexcept
436 return head ==
nullptr;
501 assert(
NEXT(link) ==
nullptr);
505 assert(
tail ==
nullptr);
520 assert(link !=
nullptr and NEXT(link) ==
nullptr);
524 assert(
tail ==
nullptr);
619 NEXT(link) = list.head;
620 NEXT(list.tail) = link_next;
625 list.head = list.tail =
nullptr;
776 while (q !=
tail and q !=
nullptr)
780 if (q ==
tail or q ==
nullptr)
794 r.tail = r_head ==
nullptr ? nullptr :
tail;
851 assert(list.is_empty());
853 list.head =
NEXT(link);
854 list.tail = list.head ==
nullptr ? nullptr :
tail;
857 NEXT(link) =
nullptr;
971 return curr !=
nullptr;
1154 for (
size_t i = 0; i < n; ++i)
1159namespace htlist_detail {
1221template <
typename T =
int>
1234 using CtorBase::CtorBase;
1237 template <
typename U>
1264 [[nodiscard]]
size_t size() const noexcept
1281 static_assert(std::is_copy_constructible_v<T> or std::is_move_constructible_v<T>,
1282 "No copy assign for T");
1285 return p->get_data();
1290 static_assert(std::is_copy_constructible_v<T> or std::is_move_constructible_v<T>,
1291 "No copy assign for T");
1294 return p->get_data();
1337 return insert(std::forward<T>(item));
1349 return push(std::forward<T>(item));
1398 delete static_cast<Snodenc<T> *
>(list.HTList::remove_head_ne());
1425 if constexpr (std::is_nothrow_move_constructible_v<T>)
1430 T ret_val = std::move(p->get_data());
1449 if constexpr (std::is_nothrow_move_constructible_v<T>)
1454 T ret_val = std::move(p->get_data());
1697 if constexpr (std::is_nothrow_move_constructible_v<T>)
1701 T ret_val = std::move(p->get_data());
1744 for (
auto it = this->
get_it(); it.has_curr(); it.next())
1745 ret.
insert(it.get_curr());
1755 template <
class Equal = std::equal_to<T>>
1760 const T &item = it.get_curr_ne();
1764 auto *removed =
static_cast<Snodenc<T> *
>(it.del_ne());
1794 template <
class Equal = std::equal_to<T>>
1798 if (
const T &item = it.get_curr();
eq(item))
1801 auto *removed =
static_cast<Snodenc<T> *
>(it.HTList::Iterator::del());
1847 for (
auto it =
l.
get_it(); it.has_curr(); it.next_ne())
1941 return insert(std::move(tmp));
2042 for (
size_t i = 1; i < n - n / 2; ++i)
2048 r.num_items = n / 2;
2085template <
class Container>
2088 return c.template maps<typename Container::Item_Type>([](
const auto &d) ->
const auto &
2094template <
typename T>
2102template <
typename T>
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.
Read-only view of an Aleph iterator: the iterator of a constant container.
Iterator on the items of list.
Iterator() noexcept=default
The type of container.
DynList * list_ptr() const noexcept
T & get_curr() const
Return the current item.
T del()
Remove the current item of the iterator.
Iterator(const DynList &)=delete
A constant list is iterated through Const_Iterator.
Slinknc * del_ne() noexcept
Remove the current node, which the caller takes, and move the iterator forward; the iterator must hav...
T del_whose_move_throws()
T & get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Doubly-linked list (defined in tpl_dynList.H).
T & get_first()
Return the first item of the list.
void remove_all_and_delete() noexcept
Delete all the items, as empty() does.
T remove(Equal eq)
Remove the first element matching an equality criteria.
size_t split_list_ne(DynList &l, DynList &r) noexcept
Split the list in two.
void cut_list(Slinknc *link, DynList &list) noexcept
See cut(Slinknc * link, DynList & list).
DynList(DynList &&l) noexcept
Initialize the list with all the items of l moved to this.
T & put(T &&item)
See insert(T && item).
const T & get_first() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
T remove_ne(Equal eq) noexcept
size_t split(DynList &l, DynList &r) noexcept
See split_list_ne(DynList & l, DynList & r).
T & append(const T &item)
const T & get_last() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
T remove_ne() noexcept(std::is_nothrow_move_constructible_v< T >)
Remove the first item of the list, which must not be empty.
Slinknc * get_tail() const noexcept=delete
T & get_first_ne() noexcept
Return the first item of the list without exception.
size_t split_list(DynList &l, DynList &r) noexcept
See split_list_ne(DynList & l, DynList & r).
DynList & operator=(const DynList &l)
Assign to this a copy of l
DynList() noexcept
Initialize an empty list. It allocates nothing.
Slinknc * get_head() const noexcept=delete
T & insert(const T &item)
DynList & append(DynList &&list) noexcept
Append listat the end of this by movement.
void concat(DynList &l) noexcept
Append the items of l to this, in constant time; l becomes empty.
T & operator[](const size_t &i)
Array-style access to the i-th item. Equivalent to get(i).
const T & get_first_ne() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
friend void in_place_transpose(DynList< DynList< U > > &l)
T remove_first_whose_move_throws()
T & get_last()
Return the last item of the list.
DynList reverse() const
Return a reversed copy of this.
T & get_last_ne() noexcept
Return the last item of the list without exception.
T & __insert(Snodenc< T > *p) noexcept
T remove()
Remove the first item of the list.
DynList(const DynList &l)
Initialize a list with a copy of all the items of list l
void cut(Slinknc *link, DynList &list) noexcept
Move to list, which must be empty, the items that follow the node link of this.
Slinknc * remove_head_ne() noexcept
Remove the first node of the list, which must not be empty; the caller takes the node,...
T & get(const size_t i)
Obtains a modifiable reference to the i-th item of this.
void clear() noexcept
Empties the container.
DynList & insert(const DynList &list)
Insert to this a copy of list.
void concat_list(DynList &l) noexcept
See concat(DynList & l).
T remove_first()
See remove().
T remove_first_ne() noexcept(std::is_nothrow_move_constructible_v< T >)
See remove_ne().
T & push(T &&item)
See insert(T && item).
const T & top() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
T & top()
See get_first().
void reset() noexcept
Forget all the nodes of the list, without deleting them, as HTList::reset() does; the list becomes em...
size_t size() const noexcept
Return the number of items of the list, in constant time.
DynList & insert(DynList &&list) noexcept
Insert listat the beginning of this by movement.
T & push(const T &item)
See insert(const T & item).
const T & get_last_ne() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
T & insert(T &&item)
Insert a new item by movement.
T & __append(Snodenc< T > *p) noexcept
T & put(const T &item)
See insert(const T & item).
DynList & reverse() noexcept
void empty() noexcept
empty the list
DynList & swap(DynList &l) noexcept
Slinknc * remove_head()
Remove the first node of the list; the caller takes the node, and its item.
DynList & append(const DynList &list)
Append to this a copy of list.
HTList * get_list_ptr() const noexcept
The list of the iterator, for the iterators of the derived lists.
Slinknc * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
long get_pos() const noexcept
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
See reset().
bool is_in_last() const noexcept
Return true if the iterator is positioned on the last item.
bool is_last() const noexcept
Slinknc * get_curr() const
Iterator & operator=(const Iterator &it) noexcept
bool has_curr() const noexcept
bool is_in_first() const noexcept
Return true if the iterator is positioned on the first item.
void reset() noexcept
Reset the iterator at the first item.
Slinknc * del_ne() noexcept
Remove the current item and move the iterator one position forward, without checking that there is a ...
Iterator() noexcept=default
Iterator(const Iterator &)=default
void end() noexcept
Set the iterator to its end position, which has not.
Single linked list of nodes.
Slinknc * get_first() const noexcept
void push(Slinknc *link) noexcept
void put(Slinknc *link) noexcept
size_t reverse_list() noexcept
See reverse().
void remove_all_and_delete() noexcept
Slinknc * get_tail() const noexcept
size_t reverse() noexcept
It inverts all list elements. It returns list size.
void insert(HTList &l) noexcept
Insert starting in link (contained in 'this' list) the.
void cut(Slinknc *link, HTList &list) noexcept
It cuts 'this' over 'link' element and it puts all.
void cut_list(Slinknc *link, HTList &list) noexcept
See cut(Slinknc * link, HTList & list).
constexpr bool is_empty() const noexcept
Slinknc * remove_head()
Remove the header item from the list.
void insert(Slinknc *link, HTList &list) noexcept
Insert a list into this after one of its items.
Slinknc * get_head() const noexcept
void rotate_left(size_t n)
Rotate to left the list n positions.
void concat_list(HTList &l) noexcept
See concat(HTList & l).
HTList & swap(HTList &l) noexcept
Slinknc * pop()
Remove the first item of this.
void append(Slinknc *link) noexcept
void append(HTList &l) noexcept
size_t split_list(HTList &l, HTList &r) noexcept
It divides 'this' into two equal lists without modifying.
Slinknc * remove_first_ne() noexcept
Remove the header item from the list.
size_t split(HTList &l, HTList &r) noexcept
See split_list(HTList & l, HTList & r).
size_t size() const noexcept
Count the number of elements of the list.
bool remove(Slinknc *link)
void insert(Slinknc *link) noexcept
Slinknc * remove_head_ne() noexcept
It deletes head element (first one). Return deleted.
bool is_unitarian() const noexcept
Return true if the list contains exactly just one.
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.
Slinknc * get_first_ne() const noexcept
Return the first item of the list; the list must not be empty.
bool is_unitarian_or_empty() const noexcept
Return true if list contains one element or is empty.
void reset_first() noexcept
Reset the iterator to the first link on the list.
bool has_curr() const noexcept
Return true if the iterator is positioned on a valid link.
Slinknc * get_curr() const
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
T & to_data() noexcept
Return the item of the Snodenc<T> that this is.
Slinknc *& get_next() noexcept
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
void insert(Slinknc *p) noexcept
insert(p) inserts the node pointed by p after this.
Snodenc(T &&item)
Construct by moving item
Snodenc *& get_first() noexcept
Return the first node of the list whose header is this.
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
T & get_data() noexcept
Return a modifiable reference to the data.
Snodenc * remove_first() noexcept
See remove_next().
Snodenc * remove_next() noexcept
Mixin providing equality comparison for sequence containers.
Common methods to the Aleph-w ( ) containers.
and
Insert a new element into the container by constructing it from the given args.
Common sequential searching methods on containers.
auto get_it()
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)
and
Check uniqueness with explicit hash + equality functors.
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)
static std::atomic< bool > init
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
The number of items of a DynList, which its operations keep.
size_t num_items
The number of items of the list.
Generic list of items stored in a container.
Generic traversal of the container through its iterator.
Special constructors common to Aleph-w ( ) containers.