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

Link of a single linked list non-circular and without header node. More...

#include <htlist.H>

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

Classes

class  Iterator
 Iterator on single links. More...
 

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.
 
Slinkncoperator= (const Slinknc &) noexcept
 Dummy asignation; link is set to nullptr.
 
Slinknc *& get_next () noexcept
 getter
 
void insert (Slinknc *p) noexcept
 Insert p after this
 
Slinkncremove_next () noexcept
 Remove for linked list the node pointed by this
 
template<typename T >
Snodenc< T > * to_snodenc () noexcept
 Convert this to a Snodenc<T>.
 
template<typename T >
Tto_data () noexcept
 
template<typename T >
const Snodenc< T > * to_snodenc () const noexcept
 
template<typename T >
const Tto_data () const noexcept
 

Private Attributes

Slinkncnext = nullptr
 

Detailed Description

Link of a single linked list non-circular and without header node.

Note
STRICT ALIASING DESIGN NOTE:

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):

template <typename Derived>
class Slinknc_Base {
Derived* next = nullptr; // Type is already correct
public:
Derived*& get_next() { return next; } // No cast needed
};
template <typename T>
class Snodenc : public Slinknc_Base<Snodenc<T>> { ... };
void next()
Advance all underlying iterators (bounds-checked).
Definition ah-zip.H:175
DynList< T > maps(const C &c, Op op)
Classic map operation.

This refactoring is left for future work to avoid breaking changes.

Definition at line 99 of file htlist.H.

Constructor & Destructor Documentation

◆ ~Slinknc()

virtual Aleph::Slinknc::~Slinknc ( )
virtualdefault

◆ Slinknc() [1/2]

Aleph::Slinknc::Slinknc ( )
inlinenoexcept

Init to nullptr.

Definition at line 113 of file htlist.H.

◆ Slinknc() [2/2]

Aleph::Slinknc::Slinknc ( const Slinknc )
inlinenoexcept

Dummy copy constructor.

Link is set to nullptr

Definition at line 119 of file htlist.H.

Member Function Documentation

◆ get_next()

Slinknc *& Aleph::Slinknc::get_next ( )
inlinenoexcept

getter

Definition at line 139 of file htlist.H.

References next.

Referenced by Aleph::Snodenc< T >::get_next(), and TEST_F().

◆ insert()

void Aleph::Slinknc::insert ( Slinknc p)
inlinenoexcept

Insert p after this

insert(p) inserts the node pointed by p after this.

Parameters
[in]ppointer to link (or node)

Definition at line 159 of file htlist.H.

References Aleph::maps(), 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(), and TEST_F().

◆ is_empty()

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

Return true if this is empty.

Definition at line 108 of file htlist.H.

References next.

Referenced by Aleph::Slinknc::Iterator::init(), TEST(), TEST_F(), and TEST_F().

◆ operator=()

Slinknc & Aleph::Slinknc::operator= ( const Slinknc )
inlinenoexcept

Dummy asignation; link is set to nullptr.

Definition at line 132 of file htlist.H.

References next.

◆ remove_next()

Slinknc * Aleph::Slinknc::remove_next ( )
inlinenoexcept

Remove for linked list the node pointed by this

Returns
a pointer to the removed node

Definition at line 177 of file htlist.H.

References Aleph::maps(), next, and Aleph::HTList::reset().

Referenced by Aleph::Snodenc< T >::remove_next().

◆ reset()

void Aleph::Slinknc::reset ( )
inlinenoexcept

Reset the link to nullptr.

Definition at line 124 of file htlist.H.

References next.

Referenced by Aleph::HTList::remove().

◆ to_data() [1/2]

template<typename T >
const T & Aleph::Slinknc::to_data ( ) const
inlinenoexcept

Definition at line 450 of file htlist.H.

References Aleph::maps().

◆ to_data() [2/2]

template<typename T >
T & Aleph::Slinknc::to_data ( )
inlinenoexcept

Definition at line 445 of file htlist.H.

References Aleph::maps().

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

◆ to_snodenc() [1/2]

template<typename T >
const Snodenc< T > * Aleph::Slinknc::to_snodenc ( ) const
inlinenoexcept

Definition at line 440 of file htlist.H.

◆ to_snodenc() [2/2]

template<typename T >
Snodenc< T > * Aleph::Slinknc::to_snodenc ( )
inlinenoexcept

Convert this to a Snodenc<T>.

Note
Invalid and probably buggy behavior if this is not a valid pointer

Definition at line 434 of file htlist.H.

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

Member Data Documentation

◆ next


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