56 template <
typename T>
class Dnode;
108 template <
typename T>
144 link->next->prev =
this;
145 link->prev->next =
this;
152 if (link->is_empty())
363 if (head->is_empty())
366 head->prev->next =
next;
385 if (head->is_empty())
388 head->next->prev =
prev;
420 if (head->is_empty())
618 if (link == this->prev)
625 if (link == this->next)
634 this->prev = link->
prev;
784 {
return curr == it.curr; }
788 {
return curr != it.curr; }
864 for (
size_t i = 0; i < n; ++i)
878 for (
size_t i = 0; i < n; ++i)
888 for (;
itor.has_curr();
itor.next_ne())
890 node =
itor.get_curr();
901 node =
itor.get_curr();
943# define DLINK_TO_TYPE(type_name, link_name) \
944 inline static type_name * dlink_to_##type_name(Dlink * link) noexcept \
946 type_name * ptr_zero = 0; \
947 size_t offset_link = reinterpret_cast<size_t>(&(ptr_zero->link_name)); \
948 char * address_type = reinterpret_cast<char*>(link) - offset_link; \
949 return reinterpret_cast<type_name *>(address_type); \
993# define LINKNAME_TO_TYPE(type_name, link_name) \
994 inline static type_name * link_name##_to_##type_name(Dlink * link) noexcept \
996 type_name * ptr_zero = 0; \
997 size_t offset_link = reinterpret_cast<size_t>(&(ptr_zero->link_name)); \
998 char * address_type = reinterpret_cast<char*>(link) - offset_link; \
999 return reinterpret_cast<type_name *>(address_type); \
1029# define DLINK_TO_BASE(type_name, link_name) \
1030 inline static type_name * dlink_to_base(Dlink * link) noexcept \
1032 type_name * ptr_zero = 0; \
1033 size_t offset_link = reinterpret_cast<size_t>(&(ptr_zero->link_name)); \
1034 char * address_type = reinterpret_cast<char*>(link) - offset_link; \
1035 return reinterpret_cast<type_name *>(address_type); \
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.
Core header for the Aleph-w library.
void put_itor_at_the_end(Itor &it) noexcept
Iterator(const Dlink &list) noexcept
Initialize an iterator on the first item of list.
void set(Dlink *new_curr) noexcept
Set the current node .
void next_ne() noexcept
Move the iterator one position backward guaranteeing no exception.
bool is_in_last() const noexcept
Return true if the iterator is positiones on the last item.
constexpr bool is_in_first() const noexcept
Return true if the iterator is positiones on the first item.
bool has_curr() const noexcept
Return true if the iterator has current item.
Dlink * get_curr() const
Return the current node of iterator.
constexpr bool verify(const Iterator &it) const noexcept
Return true if this and it are on the same list.
void next()
Move the iterator one position forward.
Dlink * del()
Remove from the list the current node and move the iterator one position forward.
void prev()
Move the iterator one position backward.
Dlink * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
void prev_ne() noexcept
Move the iterator one position backward guaranteeing no exception.
Dlink * del_ne() noexcept
constexpr bool verify(Dlink *l) const noexcept
Return true if the iterator is on the list pointed by l
constexpr bool operator==(const Iterator &it) const noexcept
Return true if this and it are positioned on the same item.
void reset_last() noexcept
Reset the iterator to the last item of list.
void end() noexcept
Put the iterator out of range.
void reset_first() noexcept
Reset the iterator to the first item of list.
constexpr bool operator!=(const Iterator &it) const noexcept
Return true if this and it hace different states.
Iterator(Dlink *head_ptr) noexcept
Initialize an iterator on the first item of the list pointed by head_ptr.
bool is_last() const noexcept
Doubly linked circular list node.
void wrap_header(Dlink *l) noexcept
Wrap a header to a list (without header).
Dlink *& get_next() const noexcept
Return the link that is after this
void concat_list(Dlink &head) noexcept
void remove_all_and_delete() noexcept
Remove and free memory for all the items of list.
Dlink * remove_next() noexcept
Remove the item that is after this
void concat_list(Dlink *head) noexcept
Concatenate list head to list this
constexpr bool is_unitarian_or_empty() const noexcept
Return true if this (as header node) has zero or one element.
constexpr Dlink *& get_last() const noexcept
If this is a header node, it return the last node of this
Dlink * remove_first() noexcept
constexpr Dlink *& get_first() const noexcept
If this is a header node, it return the first node of this
void insert_list(Dlink *head) noexcept
Insert the list head before this
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
size_t reverse_list() noexcept
Reverse the list.
void reset() noexcept
Reset this
void rotate_right(size_t n)
Analogous to rotate_left() but to right.
constexpr Dlink *& get_last_ne() const noexcept
If this is a header node, it return the last node of this
void append(Dlink *node) noexcept
Insert node before this.
size_t reverse() noexcept
Dlink() noexcept
Initialize a node or an empty list.
Dlink * del() noexcept
Remove this from the list. this must not be a header node.
void swap(Dlink *link) noexcept
Swap this with list whose header is link.
constexpr bool is_unitarian() const noexcept
Return true if this (as header node) has exactly one element.
Dlink * remove_last() noexcept
Dnode< T > * to_dnode() noexcept
void rotate_left(size_t n)
Rotate to left the list n positions.
bool check()
Return true if the list is consistent.
size_t split_list(Dlink &l, Dlink &r) noexcept
Dlink *& get_prev() const noexcept
Return the link that is before this
Dlink(const Dlink &l) noexcept
Copy constructor.
void push(Dlink *node) noexcept
void append_list(Dlink *head) noexcept
Insert the list head after this
Dlink cut_list(Dlink *link) noexcept
Cut this from link.
Dlink * remove_last_ne() noexcept
void insert(Dlink *node) noexcept
Insert node after this.
Dlink * remove_prev() noexcept
Remove the item that is before this
constexpr Dlink *& get_first_ne() const noexcept
If this is a header node, it return the first node of this
size_t split_list_ne(Dlink &l, Dlink &r) noexcept
Split this in the middle in two lists.
void splice(Dlink *l) noexcept
Insert a list l without header node after the node this.
Dlink(Dlink &&l) noexcept
Construct a new list with the items of l moved.
void swap(Dlink &l) noexcept
Swap this with list whose header is l.
Dlink & operator=(const Dlink &l) noexcept
Copy assignation.
Dlink * remove_first_ne() noexcept
Node belonging to a double circular linked list with header node.
T & insert(const T &item)
Insert a new item by copy.
T & append(const T &item)
Append a new item by copy.
constexpr bool is_empty() const noexcept
Return true if list is empty.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
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.