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
 

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
 
void insert (Slinknc *p) noexcept
 insert(p) inserts the node pointed by p after this.
 
Slinkncremove_next () noexcept
 
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>> { ... };
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
void next()
Advance all underlying iterators (bounds-checked).
Definition ah-zip.H:171

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

Definition at line 94 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 107 of file htlist.H.

◆ Slinknc() [2/2]

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

Dummy copy constructor.

Link is set to nullptr

Definition at line 111 of file htlist.H.

Member Function Documentation

◆ get_next()

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

Definition at line 129 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) inserts the node pointed by p after this.

Parameters
[in]ppointer 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().

◆ is_empty()

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

Return true if this is empty.

Definition at line 103 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 122 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 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().

◆ reset()

void Aleph::Slinknc::reset ( )
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().

◆ to_data() [1/2]

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

Definition at line 371 of file htlist.H.

References Aleph::divide_and_conquer_partition_dp().

◆ to_data() [2/2]

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

◆ to_snodenc() [1/2]

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

Definition at line 361 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 355 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: