|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Link of a single linked list non-circular and without header node. More...
#include <htlist.H>
Classes | |
| class | Iterator |
Public Member Functions | |
| virtual | ~Slinknc ()=default |
| constexpr bool | is_empty () const noexcept |
Return true if this is empty. | |
| Slinknc () noexcept | |
| Init to nullptr. | |
| Slinknc (const Slinknc &) noexcept | |
| Dummy copy constructor. | |
| void | reset () noexcept |
| Reset the link to nullptr. | |
| Slinknc & | operator= (const Slinknc &) noexcept |
| Dummy asignation; link is set to nullptr. | |
| Slinknc *& | get_next () noexcept |
| void | insert (Slinknc *p) noexcept |
insert(p) inserts the node pointed by p after this. | |
| Slinknc * | remove_next () noexcept |
| template<typename T > | |
| Snodenc< T > * | to_snodenc () noexcept |
Convert this to a Snodenc<T>. | |
| template<typename T > | |
| T & | to_data () noexcept |
| template<typename T > | |
| const Snodenc< T > * | to_snodenc () const noexcept |
| template<typename T > | |
| const T & | to_data () const noexcept |
Private Attributes | |
| Slinknc * | next = nullptr |
Link of a single linked list non-circular and without header node.
This class stores next as Slinknc*. Derived classes like Snodenc<T> need to return Snodenc<T>*& from get_next(), which requires a reinterpret_cast. This violates C++ strict aliasing rules and requires the compiler flag -fno-strict-aliasing for correct behavior.
A cleaner design would use CRTP (Curiously Recurring Template Pattern):
This refactoring is left for future work to avoid breaking changes.
|
virtualdefault |
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 129 of file htlist.H.
References next.
Referenced by Aleph::Snodenc< T >::get_next(), and TEST_F().
insert(p) inserts the node pointed by p after this.
| [in] | p | pointer to link (or node) |
Definition at line 143 of file htlist.H.
References Aleph::divide_and_conquer_partition_dp(), and next.
Referenced by Slinknc_of_5_items::Slinknc_of_5_items(), Aleph::insert_sorted(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Remove for linked list the node pointed by `this`
Definition at line 156 of file htlist.H.
References Aleph::divide_and_conquer_partition_dp(), next, and reset().
Referenced by Aleph::Snodenc< T >::remove_next(), and TEST_F().
|
inlinenoexcept |
Reset the link to nullptr.
Definition at line 115 of file htlist.H.
References next.
Referenced by Aleph::HTList::remove(), Aleph::HTList::remove_head_ne(), and remove_next().
Definition at line 371 of file htlist.H.
References Aleph::divide_and_conquer_partition_dp().
Definition at line 96 of file htlist.H.
Referenced by get_next(), Aleph::Slinknc::Iterator::init(), insert(), is_empty(), Aleph::Slinknc::Iterator::next(), Aleph::Slinknc::Iterator::next_ne(), operator=(), remove_next(), reset(), and TEST_F().