116template <
typename T =
int>
139 [[nodiscard]]
const size_t &
size() const noexcept
196 return p->get_data();
203 return p->get_data();
258 assert(list.is_empty());
267 assert(list.is_empty());
306 return this->
get_next()->get_data();
313 return this->
get_next()->get_data();
319 return this->
get_prev()->get_data();
326 return this->
get_prev()->get_data();
361 template <
bool First>
375 template <
bool First>
379 if constexpr (std::is_nothrow_move_constructible_v<T>)
381 T ret_val = std::move(item);
395 list.template delete_end<First>();
401 return std::move(item);
421 return remove_end_ne<true>();
433 return remove_end_ne<false>();
467 return append(std::forward<T>(item));
499 return insert(std::forward<T>(item));
571 l.num_elem += n - n / 2;
869 this->
append(itor.get_curr());
886 this->
append(itor.get_curr());
899 requires std::is_nothrow_default_constructible_v<T>
918 requires (not std::is_nothrow_default_constructible_v<T>
and
919 std::is_move_constructible_v<T>)
938 requires (not std::is_nothrow_default_constructible_v<T>
and
939 not std::is_move_constructible_v<T>)
964 for (
size_t i = 0; i < n && it.has_curr(); ++i)
969 return it.get_curr();
977 for (
size_t i = 0; i < n && it.has_curr(); ++i)
982 return it.get_curr();
1003 for (
auto it = this->
get_it(); it.has_curr(); it.next_ne())
1004 ret.
insert(it.get_curr());
Variadic constructor macros for containers.
Container traversal and functional operation mixins.
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.
#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.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
STL-compatible iterator adapters for Aleph containers.
DRY (Don't Repeat Yourself) utilities and macros.
#define Special_Ctors(Set_Type, Type)
Generates special constructors for containers.
Functional programming utilities for Aleph-w containers.
Iterator traits and STL-compatible iterator wrappers.
void put_itor_at_the_end(Itor &it) noexcept
Read-only view of an Aleph iterator: the iterator of a constant container.
void next_ne() noexcept
Move the iterator one position backward guaranteeing no exception.
bool has_curr() const noexcept
Return true if the iterator has current item.
void next()
Move the iterator one position forward.
void prev()
Move the iterator one position backward.
void reset_last() noexcept
Reset the iterator to the last item of list.
void reset_first() noexcept
Reset the iterator to the first item of list.
void insert_list(Dlink *head) noexcept
Insert the list head after this
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
void append(Dlink *node) noexcept
Insert node before this.
size_t reverse() noexcept
See reverse_list.
void swap(Dlink *link) noexcept
Swap this with list whose header is link.
size_t split_list(Dlink &l, Dlink &r) noexcept
Dlink * del() noexcept
Remove this from the list. this must not be a header node.
void insert(Dlink *node) noexcept
Insert node after this.
void append_list(Dlink *head) noexcept
Insert the list head before this
Iterator on a list of Dnode objects.
Dnode< T > * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Dnode< T > * get_curr() const
Return a pointer to the current node.
Node belonging to a double circular linked list with header node.
Dnode< T > *& get_next() const noexcept
Return the next node to this
Dnode< T > * remove_next() noexcept
Remove the next node to this; return its address.
Dnode< T > *& get_prev() const noexcept
Return the previous node to this
static Dnode * data_to_node(T &data) noexcept
Given an reference to the data in the node, returns a pointer to the Dnode object that contains it.
T & get_data() noexcept
Return a modifiable reference to the data contained in the node.
Dnode< T > * remove_prev() noexcept
Remove the previous node to this; return its address.
Iterator(const DynDlist< T > &)=delete
A constant list is iterated through Const_Iterator.
void append_list(DynDlist &list)
Move and append all elements of list before the current item of iterator.
T Item_Type
The type of element stored in the container.
typename Dnode< T >::Iterator Base
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
void insert(const T &item)
Insert by copy an item after the current item.
Iterator(const Iterator &)=default
T & get_curr() const
Return the current item; throw overflow_error if there is no current item.
void reset_last() noexcept
Reset the iterator to the last item.
Iterator & operator=(const Iterator &it) noexcept
void end() noexcept
Put the iterator at the end state (where there is no current item)
void prev()
Move the iterator one item backward.
long get_pos() const noexcept
Return the ordinal position of the current item.
void insert(T &&item)
Insert by movement an item after the current item.
Iterator(DynDlist< T > &list) noexcept
Iterator on the first item of the modifiable list list.
T del()
Remove from the list the current node and move the iterator one position forward.
void append(T &&item)
Append by movement an item after the current item.
void insert_list(DynDlist &list)
Move and insert all elements of list after the current item of iterator.
void reset_first() noexcept
Reset the iterator to the first item.
void append(const T &item)
Append by copy an item before the current item.
void next()
Move the iterator one item forward.
T & get_curr_ne() const noexcept
Dynamic doubly linked list with O(1) size and bidirectional access.
T & get_last_ne() noexcept
Return a modifiable reference to last item in the list.
const T & get_last_ne() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
T & operator[](const size_t n)
Return a modifiable reference to the i-th item of the list.
void insert(DynDlist &&list) noexcept
See insert(const DynDlist & list).
const size_t & size() const noexcept
Return the number of elements (constant time)
T & get_first()
Return a modifiable reference to first item in the list.
void _insert(DynDlist< T > &list) noexcept
DynDlist & reverse() noexcept
T Key_Type
The type of element that stores the container.
T & front()
If this was treated as a queue, the it returns the most oldlest inserted item.
DynDlist< T > reverse() const
Return a reversed copy of this
const T & get_first_ne() const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
T pop()
See remove_first().
T & push(T &&item)
See insert(T && item).
T remove_first_ne() noexcept(std::is_nothrow_move_constructible_v< T >)
Remove the first item of the list, which must not be empty.
T remove_first()
Remove the first item of the list; return a copy of removed item.
T & put(T &&item)
See append(T && item).
const T & top() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
DynDlist(DynDlist &&list)
Move constructor for a T whose default construction may throw and that cannot be moved,...
void split_list(DynDlist &l, DynDlist &r)
Split the list in two.
void swap(DynDlist &l) noexcept
Swap in constant time all the items of this with all the items of l (very fast!)
void remove(T &data) noexcept
Assuming that data is a reference to the item in the list, it removes the item.
T remove_last_ne() noexcept(std::is_nothrow_move_constructible_v< T >)
Remove the last item of the list, which must not be empty.
T & append(const T &item)
Append a copied item at the end of the list.
void delete_end() noexcept
void append(const DynDlist &list)
Append all the elements of list after this.
T & get_first_ne() noexcept
Return a modifiable reference to first item in the list.
T & get_last()
Return a modifiable reference to last item in the list.
DynDlist(DynDlist &&list) noexcept(std::is_nothrow_move_constructible_v< T >)
Move constructor for a T whose default construction may throw, as one that allocates,...
T Item_Type
The type of element that stores the container.
T & push(const T &item)
See insert(const T & item).
T remove_last()
Remove the last item of the list; return a copy of removed item.
T & put(const T &item)
See append(const T & item).
void empty() noexcept
@brief Empties the container.
const T & get_first() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
DynDlist & rev() noexcept
T & rear()
If this was treated as a queue, the it returns the most recently inserted item.
void split(DynDlist &l, DynDlist &r)
This is an overloaded member function, provided for convenience. It differs from the above function o...
DynDlist< T > rev() const
T & top()
See get_first().
void _append(DynDlist< T > &list) noexcept
T & _append(Dnode< T > *p) noexcept
void clear() noexcept
@brief Empties the container.
void erase(T &data) noexcept
See remove(T & data).
void append(DynDlist &&list) noexcept
See append(const DynDlist & list).
T & insert(const T &item)
Insert a copy of item at the beginning of the list.
T & _insert(Dnode< T > *p) noexcept
const T & get_last() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void insert(const DynDlist &list)
Insert all the elements of list before this.
T get()
See remove_first().
T remove_end_ne() noexcept(std::is_nothrow_move_constructible_v< T >)
DynDlist< T > & operator=(const DynDlist &list)
Assignment by copy.
T & insert(T &&item)
Insert a moved item at the beginning of the list.
DynDlist(DynDlist &&list) noexcept
Move constructor: takes in constant time the items of list, which is left empty.
void split_list_ne(DynDlist &l, DynDlist &r) noexcept
Split the list in two.
T & append(T &&item)
Append a moved item at the end of the list.
DynDlist(const DynDlist &list)
Copy constructor; all items of list are copied.
constexpr bool is_empty() const 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.
std::decay_t< typename HeadC::Item_Type > T
Generic list of items stored in a container.
Generic traversal of the container through its iterator.
Special constructors common to Aleph-w ( ) containers.
Doubly linked list node with typed data.