Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Dlink Class Reference

Doubly linked circular list node. More...

#include <dlink.H>

Inheritance diagram for Aleph::Dlink:
[legend]
Collaboration diagram for Aleph::Dlink:
[legend]

Classes

class  Iterator
 Iterator on Dlink lists. More...
 

Public Member Functions

template<typename T >
Dnode< T > * to_dnode () noexcept
 Convert this, which must be the link of a Dnode<T>, to that node.
 
template<typename T >
const Dnode< T > * to_dnode () const noexcept
 Convert this, which must be the link of a Dnode<T>, to that constant node.
 
template<typename T >
T & to_data () noexcept
 Return the item of the Dnode<T> whose link is this.
 
template<typename T >
const T & to_data () const noexcept
 Return the constant item of the Dnode<T> whose link is this.
 
 Dlink () noexcept
 Initialize a node or an empty list.
 
 Dlink (const Dlink &l) noexcept
 Copy constructor.
 
void swap (Dlink *link) noexcept
 Swap this with list whose header is link.
 
void swap (Dlink &l) noexcept
 Swap this with list whose header is l.
 
 Dlink (Dlink &&l) noexcept
 Construct a new list with the items of l moved.
 
Dlink & operator= (const Dlink &l) noexcept
 Copy assignation.
 
Dlink & operator= (Dlink &&l) noexcept
 Move assignation.
 
void reset () noexcept
 Reset this
 
void init () noexcept
 See reset().
 
constexpr bool is_empty () const noexcept
 Return true if this (as header node) is empty.
 
constexpr bool is_unitarian () const noexcept
 Return true if this (as header node) has exactly one element.
 
constexpr bool is_unitarian_or_empty () const noexcept
 Return true if this (as header node) has zero or one element.
 
void insert (Dlink *node) noexcept
 Insert node after this.
 
void push (Dlink *node) noexcept
 See insert(Dlink * node).
 
void append (Dlink *node) noexcept
 Insert node before this.
 
Dlink *& get_next () const noexcept
 Return the link that is after this
 
Dlink *& get_prev () const noexcept
 Return the link that is before this
 
constexpr Dlink *& get_first_ne () const noexcept
 If this is a header node, it return the first node of this
 
constexpr Dlink *& get_last_ne () const noexcept
 If this is a header node, it return the last node of this
 
constexpr Dlink *& get_first () const noexcept
 If this is a header node, it return the first node of this
 
constexpr Dlink *& get_last () const noexcept
 If this is a header node, it return the last node of this
 
void wrap_header (Dlink *l) noexcept
 Wrap a header to a list (without header).
 
void insert_list (Dlink *head) noexcept
 Insert the list head after this
 
void append_list (Dlink *head) noexcept
 Insert the list head before this
 
void splice (Dlink *l) noexcept
 Insert a list l without header node after the node this.
 
void concat_list (Dlink *head) noexcept
 Concatenate list head to list this
 
void concat_list (Dlink &head) noexcept
 See concat_list(Dlink * head).
 
Dlink * del () noexcept
 Remove this from the list. this must not be a header node.
 
void erase () noexcept
 See del().
 
Dlink * remove_prev () noexcept
 Remove the item that is before this
 
Dlink * remove_next () noexcept
 Remove the item that is after this
 
Dlink * remove_last_ne () noexcept
 See remove_prev().
 
Dlink * remove_first_ne () noexcept
 See remove_next().
 
Dlink * remove_last () noexcept
 See remove_prev().
 
Dlink * remove_first () noexcept
 See remove_next().
 
Dlink * top () const
 See get_next().
 
Dlink * pop ()
 See remove_next().
 
size_t reverse_list () noexcept
 Reverse the list.
 
size_t reverse () noexcept
 See reverse_list.
 
size_t split_list_ne (Dlink &l, Dlink &r) noexcept
 Split this in the middle in two lists.
 
size_t split_list (Dlink &l, Dlink &r) noexcept
 
Dlink cut_list (Dlink *link) noexcept
 Cut this from link.
 
void remove_all_and_delete () noexcept
 Remove and free memory for all the items of list.
 
void rotate_left (size_t n)
 Rotate to left the list n positions.
 
void rotate_right (size_t n)
 Analogous to rotate_left() but to right.
 
bool check ()
 Return true if the list is consistent.
 

Protected Attributes

Dlink * prev
 
Dlink * next
 

Detailed Description

Doubly linked circular list node.

Dlink is the fundamental building block for doubly linked circular lists in Aleph-w. Each node contains pointers to its previous and next neighbors, forming a circular structure. An empty list consists of a single sentinel node pointing to itself.

This class provides low-level operations for manipulating the list structure. For a higher-level interface with data storage, see Dnode and DynDlist.

Design Principles:
  • Circular structure: last->next == first, first->prev == last
  • Sentinel node: empty list has sentinel->next == sentinel
  • Intrusive design: nodes can be embedded in other structures
Complexity:
  • Insert/remove at known position: O(1)
  • Concatenate two lists: O(1)
  • Split list: O(n), a walk to the middle
  • Traverse: O(n)
Example:
Dlink header; // sentinel node
Dlink node1, node2, node3;
header.insert(&node1); // Insert after header
node1.insert(&node2); // Insert after node1
header.append(&node3); // Insert before header (at end)
// Traverse forward
for (auto it = header.get_next(); it != &header; it = it->get_next())
process(it);
See also
Dnode Node with embedded data.
DynDlist High-level dynamic doubly linked list.
Dlink::Iterator Bidirectional iterator for Dlink lists.

Definition at line 99 of file dlink.H.

Constructor & Destructor Documentation

◆ Dlink() [1/3]

Aleph::Dlink::Dlink ( )
inlinenoexcept

Initialize a node or an empty list.

Definition at line 120 of file dlink.H.

References is_empty().

◆ Dlink() [2/3]

Aleph::Dlink::Dlink ( const Dlink &  l)
inlinenoexcept

Copy constructor.

Be very careful because if l contains items, then these will be lost

Definition at line 127 of file dlink.H.

References Aleph::HTList::is_empty(), l, and reset().

◆ Dlink() [3/3]

Aleph::Dlink::Dlink ( Dlink &&  l)
inlinenoexcept

Construct a new list with the items of l moved.

This constructor takes a rvalue reference l to a list and moves it in constant time to this

Parameters
[in]lrvalue reference to the to be moved

Definition at line 192 of file dlink.H.

References l, and swap().

Member Function Documentation

◆ append()

void Aleph::Dlink::append ( Dlink *  node)
inlinenoexcept

Insert node before this.

Parameters
[in]nodepointer to an empty node (it must not be inserted in another list)

Definition at line 295 of file dlink.H.

References Aleph::and, next, and prev.

Referenced by List_of_5_nodes::List_of_5_nodes(), Aleph::__dfp_phase1(), Aleph::DynDlist< T >::_append(), Aleph::Polygon::add_vertex(), build_int_list(), build_ptr_list(), Aleph::Unconnected_Components< GT, SA >::compute_blocks(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::connect_arc(), Aleph::Polygon::copy_points(), create_list_with_header(), cut_list(), Aleph::dlink_random_search(), Aleph::dlink_random_select(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::expand(), Aleph::Find_Eulerian_Path< GT, SN, SA >::find_node_sequence(), Aleph::tree_node_detail::free_detached_tree(), Aleph::GenLhashTable< Key, BucketType, Cmp >::insert(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::insert(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::Tree_Node< T >::insert_left_sibling(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::insert_node(), main(), main(), Aleph::Q_Topological_Sort< GT, Itor, SA >::perform(), Aleph::quicksort(), Aleph::Q_Topological_Sort< GT, Itor, SA >::ranks(), rotate_left(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::search_or_insert(), Aleph::selection_sort(), DlinkRotationTest::SetUp(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), and Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::try_insert_arc().

◆ append_list()

void Aleph::Dlink::append_list ( Dlink *  head)
inlinenoexcept

Insert the list head before this

This method assumes that this is a node part of list; it is not the header node. On the other hand, head is the header node of an entire list. So, all the list head is entirely appended, in constant time, before the node this. After append, the list head becomes empty.

Parameters
[in]headheader for the list to insert

Definition at line 408 of file dlink.H.

References next, prev, and reset().

Referenced by Aleph::DynDlist< T >::_append(), and TEST_F().

◆ check()

bool Aleph::Dlink::check ( )
inline

◆ concat_list() [1/2]

void Aleph::Dlink::concat_list ( Dlink &  head)
inlinenoexcept

See concat_list(Dlink * head).

Definition at line 462 of file dlink.H.

References concat_list().

◆ concat_list() [2/2]

void Aleph::Dlink::concat_list ( Dlink *  head)
inlinenoexcept

Concatenate list head to list this

this and head are both header nodes of lists. concat_list(head) concatenates in constant time all the list head after this. After the concatenation head becomes empty.

Parameters
headheader node of list to concatenate

Definition at line 441 of file dlink.H.

References is_empty(), next, prev, reset(), and swap().

Referenced by concat_list(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::contract(), Aleph::dlink_random_search(), Aleph::dlink_random_select(), Aleph::tree_node_detail::free_detached_tree(), and Aleph::quicksort().

◆ cut_list()

Dlink Aleph::Dlink::cut_list ( Dlink *  link)
inlinenoexcept

Cut this from link.

cut_list(link) takes a valid link to an item of the list and on that link performs a cut; that is, all the items from link passes to a new list whose head is the return value.

The operation takes constant time.

Warning
Takes in account that the return value is Dlink object, not a pointer.
if link belongs to a list, then this one will be in an inconsistent state.
Parameters
[in]linkpointer to the item from which the cut will be done
Returns
a Dlink header of a new list containing the items from link

Definition at line 669 of file dlink.H.

References Aleph::and, append(), del(), is_empty(), next, prev, and swap().

Referenced by Aleph::tree_node_detail::detach_tree(), Aleph::Tree_Node< T >::insert_left_sibling(), Aleph::Tree_Node< T >::insert_leftmost_child(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ del()

◆ erase()

void Aleph::Dlink::erase ( )
inlinenoexcept

See del().

Definition at line 479 of file dlink.H.

References del().

◆ get_first()

constexpr Dlink *& Aleph::Dlink::get_first ( ) const
inlineconstexprnoexcept

◆ get_first_ne()

constexpr Dlink *& Aleph::Dlink::get_first_ne ( ) const
inlineconstexprnoexcept

If this is a header node, it return the first node of this

Definition at line 322 of file dlink.H.

References next.

◆ get_last()

constexpr Dlink *& Aleph::Dlink::get_last ( ) const
inlineconstexprnoexcept

If this is a header node, it return the last node of this

Definition at line 340 of file dlink.H.

References prev.

Referenced by Aleph::insert_sorted(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ get_last_ne()

constexpr Dlink *& Aleph::Dlink::get_last_ne ( ) const
inlineconstexprnoexcept

If this is a header node, it return the last node of this

Definition at line 328 of file dlink.H.

References prev.

◆ get_next()

◆ get_prev()

◆ init()

◆ insert()

◆ insert_list()

void Aleph::Dlink::insert_list ( Dlink *  head)
inlinenoexcept

Insert the list head after this

This method assumes that this is a node part of list; it is not the header node. On the other hand, head is the header node of an entire list. So, all the list head is entirely inserted, in constant time, after the node this. After insertion, the list head becomes empty.

Parameters
[in]headheader for the list to insert

Definition at line 386 of file dlink.H.

References next, prev, and reset().

Referenced by Aleph::DynDlist< T >::_insert(), and splice().

◆ is_empty()

constexpr bool Aleph::Dlink::is_empty ( ) const
inlineconstexprnoexcept

Return true if this (as header node) is empty.

Definition at line 250 of file dlink.H.

References Aleph::and, next, and prev.

Referenced by Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::Array_Graph(), Dlink(), Aleph::DynDlist< T >::DynDlist(), Aleph::Polygon::Vertex_Iterator::Vertex_Iterator(), Eepic_Plane::~Eepic_Plane(), Aleph::DynDlist< T >::Iterator::append_list(), Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::clear(), Aleph::compute_bipartite(), concat_list(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::contract(), cut_list(), Aleph::Polygon::delete_points(), Aleph::dlink_random_search(), Aleph::dlink_random_select(), Aleph::DynDlist< T >::empty(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::empty(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::expand(), Aleph::tree_node_detail::free_detached_tree(), Aleph::DynDlist< T >::get_first(), Aleph::Dnode< T >::get_first(), Aleph::DynDlist< T >::get_first(), Aleph::Polygon::get_first_vertex(), Aleph::DynDlist< T >::get_last(), Aleph::Dnode< T >::get_last(), Aleph::DynDlist< T >::get_last(), Aleph::Polygon::get_last_vertex(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::insert(), Aleph::DynDlist< T >::Iterator::insert_list(), Aleph::Dlink::Iterator::is_in_first(), Aleph::Dlink::Iterator::is_last(), Aleph::GenLhashTable< Key, BucketType, Cmp >::Iterator::locate_next_available_entry(), Aleph::GenLhashTable< Key, BucketType, Cmp >::Iterator::locate_next_available_entry_ne(), Aleph::GenLhashTable< Key, BucketType, Cmp >::Iterator::locate_prev_available_entry(), Aleph::GenLhashTable< Key, BucketType, Cmp >::Iterator::locate_prev_available_entry_ne(), main(), Aleph::Vertex::next_vertex(), Aleph::HalfPlaneIntersection::operator()(), operator=(), pop(), Aleph::Vertex::prev_vertex(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::print(), Aleph::quicksort(), remove_all_and_delete(), Aleph::Dnode< T >::remove_first(), Aleph::DynDlist< T >::remove_first(), Aleph::Dnode< T >::remove_last(), Aleph::DynDlist< T >::remove_last(), remove_next(), remove_prev(), reverse_list(), rotate_left(), rotate_right(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::search(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::search_or_insert(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::search_with_custom_hash(), Aleph::selection_sort(), splice(), split_list_ne(), swap(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), top(), TYPED_TEST(), TYPED_TEST(), Aleph::vertex_connectivity(), and wrap_header().

◆ is_unitarian()

constexpr bool Aleph::Dlink::is_unitarian ( ) const
inlineconstexprnoexcept

Return true if this (as header node) has exactly one element.

Definition at line 256 of file dlink.H.

References Aleph::and, next, and prev.

Referenced by Aleph::Vertex::next_vertex(), Aleph::Vertex::prev_vertex(), TEST(), TEST(), TEST(), TEST(), TEST_F(), and TEST_F().

◆ is_unitarian_or_empty()

constexpr bool Aleph::Dlink::is_unitarian_or_empty ( ) const
inlineconstexprnoexcept

Return true if this (as header node) has zero or one element.

Definition at line 262 of file dlink.H.

References next, and prev.

Referenced by Aleph::Polygon::Segment_Iterator::Segment_Iterator(), Aleph::Polygon::get_first_segment(), Aleph::Polygon::get_last_segment(), Aleph::quicksort(), TEST(), TEST(), and TEST().

◆ operator=() [1/2]

Dlink & Aleph::Dlink::operator= ( const Dlink &  l)
inlinenoexcept

Copy assignation.

Warning
Be very careful with the possibility of this has items, because these will be lost
Parameters
[in]llink to be copied

Definition at line 204 of file dlink.H.

References is_empty(), Aleph::HTList::is_empty(), l, next, and prev.

◆ operator=() [2/2]

Dlink & Aleph::Dlink::operator= ( Dlink &&  l)
inlinenoexcept

Move assignation.

Assign a rvalue list to this without copying.

Parameters
[in]lrvalue reference to the list to move from.
Note
Since l is rvalue reference, take care of that if you are interested in to avoid the copy. So, if you have a lvalue reference to a list, use std::move(), upon your responsability, if and only if you are absolutely sure that the list will not be needed after.

Definition at line 226 of file dlink.H.

References l, and swap().

◆ pop()

Dlink * Aleph::Dlink::pop ( )
inline

See remove_next().

Definition at line 558 of file dlink.H.

References ah_underflow_error_if, is_empty(), and remove_next().

Referenced by TEST().

◆ push()

void Aleph::Dlink::push ( Dlink *  node)
inlinenoexcept

See insert(Dlink * node).

Definition at line 285 of file dlink.H.

References insert().

Referenced by TEST().

◆ remove_all_and_delete()

void Aleph::Dlink::remove_all_and_delete ( )
inlinenoexcept

Remove and free memory for all the items of list.

remove_all_and_delete() remove each item of the list and call to delete operator on the removed item. At the end of call, all the items were removed, all the memory freed qand the list emptied.

Warning
This method only has sense if the items of list were dynamically allocated with new. Although That is very frequently the case, there are some exceptions. So, be sure that the items were allocated with new operator.

Definition at line 921 of file dlink.H.

References is_empty(), and remove_next().

Referenced by main(), and main().

◆ remove_first()

Dlink * Aleph::Dlink::remove_first ( )
inlinenoexcept

◆ remove_first_ne()

Dlink * Aleph::Dlink::remove_first_ne ( )
inlinenoexcept

See remove_next().

Definition at line 533 of file dlink.H.

References remove_next().

Referenced by Aleph::GenLinearHashTable< Key, BucketType, Cmp >::empty().

◆ remove_last()

Dlink * Aleph::Dlink::remove_last ( )
inlinenoexcept

See remove_prev().

Definition at line 539 of file dlink.H.

References remove_prev().

Referenced by rotate_right(), TEST(), TEST(), and TEST_F().

◆ remove_last_ne()

Dlink * Aleph::Dlink::remove_last_ne ( )
inlinenoexcept

See remove_prev().

Definition at line 527 of file dlink.H.

References remove_prev().

◆ remove_next()

Dlink * Aleph::Dlink::remove_next ( )
inlinenoexcept

Remove the item that is after this

Remove the item successor of this.

Note
If this is a header node, then this method is equivalent to remove the first node.
Warning
The successor of this must not be a header node.
Returns
a pointer to the removed node.

Definition at line 516 of file dlink.H.

References del(), is_empty(), and next.

Referenced by List_of_5_nodes::~List_of_5_nodes(), Aleph::Polygon::delete_points(), Aleph::dlink_random_search(), Aleph::dlink_random_select(), Aleph::tree_node_detail::free_detached_tree(), pop(), Aleph::quicksort(), remove_all_and_delete(), remove_first(), remove_first_ne(), Aleph::Dnode< T >::remove_first_ne(), Aleph::Dnode< T >::remove_next(), and reverse_list().

◆ remove_prev()

Dlink * Aleph::Dlink::remove_prev ( )
inlinenoexcept

Remove the item that is before this

Remove the item predecessor of this.

Note
If this is a header node, then this method is equivalent to remove the last node.
Warning
The predecessor of this must not be a header node.
Returns
a pointer to the removed node.

Definition at line 495 of file dlink.H.

References del(), is_empty(), and prev.

Referenced by remove_last(), remove_last_ne(), Aleph::Dnode< T >::remove_last_ne(), and Aleph::Dnode< T >::remove_prev().

◆ reset()

void Aleph::Dlink::reset ( )
inlinenoexcept

Reset this

reset() reinitialize the node to point to itself. So, all the context is lost. Use with care.

Definition at line 238 of file dlink.H.

References next, and prev.

Referenced by Dlink(), append_list(), concat_list(), del(), init(), insert_list(), split_list_ne(), swap(), and TEST_F().

◆ reverse()

size_t Aleph::Dlink::reverse ( )
inlinenoexcept

See reverse_list.

Definition at line 584 of file dlink.H.

References reverse_list().

Referenced by Aleph::DynDlist< T >::reverse().

◆ reverse_list()

size_t Aleph::Dlink::reverse_list ( )
inlinenoexcept

Reverse the list.

Returns
the number of items that has the list

Definition at line 568 of file dlink.H.

References counter, insert(), is_empty(), remove_next(), and swap().

Referenced by reverse(), TEST(), TEST(), TEST(), and TEST().

◆ rotate_left()

void Aleph::Dlink::rotate_left ( size_t  n)
inline

Rotate to left the list n positions.

rotate_left(n) rotates the items to left n positions. For example, if the list is as follows:

l0, l1, l2, l3, l4, l5, l6, l7, l8, l9

Then rotate_left(4) produces the following state:

l4, l5, l6, l7, l8, l9, l0, l1, l2, l3

Parameters
[in]nthe number of position to be rotated
Exceptions
domain_errorif list is empty

Definition at line 941 of file dlink.H.

References ah_domain_error, append(), is_empty(), and remove_first().

Referenced by TEST(), TEST(), TEST(), and TEST_F().

◆ rotate_right()

void Aleph::Dlink::rotate_right ( size_t  n)
inline

Analogous to rotate_left() but to right.

Definition at line 955 of file dlink.H.

References ah_domain_error, insert(), is_empty(), and remove_last().

Referenced by TEST(), and TEST_F().

◆ splice()

void Aleph::Dlink::splice ( Dlink *  l)
inlinenoexcept

Insert a list l without header node after the node this.

Parameters
[in]llist without header node to be inserted after this

Definition at line 424 of file dlink.H.

References insert_list(), is_empty(), l, and wrap_header().

Referenced by Aleph::tree_node_detail::detach_tree().

◆ split_list()

size_t Aleph::Dlink::split_list ( Dlink &  l,
Dlink &  r 
)
inlinenoexcept

Definition at line 645 of file dlink.H.

References l, r, and split_list_ne().

Referenced by Aleph::DynDlist< T >::split_list_ne(), TEST(), TEST(), TEST(), and TEST_F().

◆ split_list_ne()

size_t Aleph::Dlink::split_list_ne ( Dlink &  l,
Dlink &  r 
)
inlinenoexcept

Split this in the middle in two lists.

split_list(l, r) cuts this in its middle: l takes its first n - n / 2 nodes and r the last n / 2, in their order. After the operation, this becomes empty. It walks from both ends to the middle and splices the two halves, without moving the nodes one by one.

Note
l and r must be empty before calling this method.
Parameters
[out]lthe first n - n / 2 nodes of this
[out]rthe last n / 2 nodes of this
Returns
total number of nodes of both lists (which is the same number of nodes that this had before the split)

Definition at line 604 of file dlink.H.

References Aleph::and, is_empty(), Aleph::HTList::is_empty(), l, next, prev, r, and reset().

Referenced by split_list().

◆ swap() [1/2]

void Aleph::Dlink::swap ( Dlink &  l)
inlinenoexcept

Swap this with list whose header is l.

swap(l) swaps the content og this with all the content of the list referenced by l. The operation is performed in constant time independently of sizes of both lists.

Parameters
[in]llist to be swapped with this

Definition at line 180 of file dlink.H.

References l, and swap().

◆ swap() [2/2]

void Aleph::Dlink::swap ( Dlink *  link)
inlinenoexcept

Swap this with list whose header is link.

swap(link) swaps the content og this with all the content of the list pointed by link. The operation is performed in constant time independently of sizes of both lists.

Parameters
[in]linkpointer to the list to be swapped

Definition at line 141 of file dlink.H.

References Aleph::and, is_empty(), next, prev, and reset().

Referenced by Dlink(), Aleph::Dnode< T >::Dnode(), Aleph::Polygon::Polygon(), concat_list(), cut_list(), Aleph::dlink_random_search(), operator=(), Aleph::Polygon::operator=(), reverse_list(), Aleph::selection_sort(), Aleph::Array_Graph< __Graph_Node, __Graph_Arc >::swap(), swap(), Aleph::Dnode< T >::swap(), Aleph::DynDlist< T >::swap(), Aleph::GenLinearHashTable< Key, BucketType, Cmp >::swap(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::swap(), Aleph::Net_Graph< NodeT, ArcT >::swap_contents(), TEST(), TEST(), TEST_F(), and TEST_F().

◆ to_data() [1/2]

template<typename T >
const T & Aleph::Dlink::to_data ( ) const
noexcept

Return the constant item of the Dnode<T> whose link is this.

Definition at line 355 of file tpl_dnode.H.

◆ to_data() [2/2]

template<typename T >
T & Aleph::Dlink::to_data ( )
noexcept

Return the item of the Dnode<T> whose link is this.

Definition at line 350 of file tpl_dnode.H.

References Aleph::Dnode< T >::get_data().

Referenced by TEST().

◆ to_dnode() [1/2]

template<typename T >
const Dnode< T > * Aleph::Dlink::to_dnode ( ) const
noexcept

Convert this, which must be the link of a Dnode<T>, to that constant node.

Definition at line 345 of file tpl_dnode.H.

◆ to_dnode() [2/2]

template<typename T >
Dnode< T > * Aleph::Dlink::to_dnode ( )
noexcept

Convert this, which must be the link of a Dnode<T>, to that node.

Definition at line 340 of file tpl_dnode.H.

Referenced by TEST().

◆ top()

Dlink * Aleph::Dlink::top ( ) const
inline

See get_next().

Definition at line 551 of file dlink.H.

References ah_underflow_error_if, get_next(), and is_empty().

Referenced by TEST().

◆ wrap_header()

void Aleph::Dlink::wrap_header ( Dlink *  l)
inlinenoexcept

Wrap a header to a list (without header).

Sometimes, especially for low level applications, you coult manage linked list without header nodes. In this case, in order to profit some operations expeting a list with header, you could "wrap" a temporal header and use the list and the operations of this class.

For example, suppose we have a list l without header node and we wish to insert it into a another list with a header node. In this case, we wrap a header to l as follows:

Dlink h; h.wrap_header(l);

Now, if we have a node p of another list, we could insert l after p as follows:

p->insert_list(&h);

After this operation h becomes empty and the list l is inserted after the node p

Parameters
[in]lfirst node of a double and circular list without header node

Definition at line 370 of file dlink.H.

References Aleph::DynList< T >::append(), is_empty(), and l.

Referenced by Aleph::tree_node_detail::free_detached_tree(), and splice().

Member Data Documentation

◆ next

◆ prev


The documentation for this class was generated from the following files: