SLListBase Class Reference

Base for singly-linked lists. More...

Classes

class  const_iterator
 A primitive const node iterator. More...
 
class  iterator
 A primitive non-const node iterator. More...
 
struct  link
 The structure for a singly-linked storage node. More...
 

Public Member Functions

 SLListBase ()=default
 Default construct. More...
 
 SLListBase (const SLListBase &)=delete
 No copy construct. More...
 
void operator= (const SLListBase &)=delete
 No copy assignment. More...
 
 ~SLListBase ()=default
 Destructor. More...
 
label size () const noexcept
 The number of elements in list. More...
 
bool empty () const noexcept
 True if the list is empty. More...
 
link * first ()
 Return first entry. More...
 
const link * first () const
 Return const access to first entry. More...
 
link * last ()
 Return last entry. More...
 
const link * last () const
 Return const access to last entry. More...
 
void insert (link *item)
 Add at head of list. More...
 
void append (link *item)
 Add at tail of list. More...
 
link * removeHead ()
 Remove and return head. More...
 
link * remove (link *item)
 
link * remove (iterator &iter)
 
void clear ()
 Clear the list. More...
 
void swap (SLListBase &lst)
 Swap the contents of list. More...
 
void transfer (SLListBase &lst)
 
iterator begin ()
 Iterator to first item in list with non-const access. More...
 
const_iterator cbegin () const
 Iterator to first item in list with const access. More...
 
const_iterator crbegin () const =delete
 No reverse iteration. More...
 
const iterator & end ()
 End of list for iterators. More...
 
const const_iterator & cend () const
 End of list for iterators. More...
 
const const_iterator & crend () const =delete
 No reverse iteration. More...
 

Protected Member Functions

template<class IteratorType >
IteratorType iterator_first () const
 Return iterator to first item or end-iterator if list is empty. More...
 
template<class IteratorType >
IteratorType iterator_last () const
 Return iterator to last item or end-iterator if list is empty. More...
 

Static Protected Member Functions

template<class IteratorType >
static const IteratorType & iterator_end ()
 Factory method to return an iterator end. More...
 
template<class IteratorType >
static const IteratorType & iterator_rend ()=delete
 Factory method to return an iterator rend. More...
 

Friends

class iterator
 
class const_iterator
 

Detailed Description

Base for singly-linked lists.

The iterators associated with the list only have a core functionality for navigation, with additional functionality to be added by inheriting classes. The node iterators always have a node-pointer as the first member data, which allows reinterpret_cast from anything else with a nullptr as its first data member. The nullObject is such an item (with a nullptr data member).

Source files

Definition at line 61 of file SLListBase.H.

Constructor & Destructor Documentation

◆ SLListBase() [1/2]

SLListBase ( )
default

Default construct.

◆ SLListBase() [2/2]

SLListBase ( const SLListBase &  )
delete

No copy construct.

◆ ~SLListBase()

~SLListBase ( )
default

Destructor.

Member Function Documentation

◆ iterator_end()

const IteratorType & iterator_end ( )
inlinestaticprotected

Factory method to return an iterator end.

Simply reinterprets a NullObject as a SLListBase iterator.

Definition at line 35 of file SLListBaseI.H.

References Foam::nullObjectPtr.

◆ iterator_rend()

static const IteratorType& iterator_rend ( )
staticprotecteddelete

Factory method to return an iterator rend.

Deleted for SLListBase

◆ iterator_first()

IteratorType iterator_first ( ) const
inlineprotected

Return iterator to first item or end-iterator if list is empty.

Removes constness which the caller promises to manage.

Definition at line 42 of file SLListBaseI.H.

◆ iterator_last()

IteratorType iterator_last ( ) const
inlineprotected

Return iterator to last item or end-iterator if list is empty.

Removes constness which the caller promises to manage.

Definition at line 57 of file SLListBaseI.H.

◆ operator=()

void operator= ( const SLListBase &  )
delete

No copy assignment.

◆ size()

Foam::label size ( ) const
inlinenoexcept

The number of elements in list.

Definition at line 73 of file SLListBaseI.H.

◆ empty()

bool empty ( ) const
inlinenoexcept

True if the list is empty.

Definition at line 79 of file SLListBaseI.H.

◆ first() [1/2]

Foam::SLListBase::link * first ( )
inline

Return first entry.

Definition at line 86 of file SLListBaseI.H.

References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ first() [2/2]

const Foam::SLListBase::link * first ( ) const
inline

Return const access to first entry.

Definition at line 99 of file SLListBaseI.H.

References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ last() [1/2]

Foam::SLListBase::link * last ( )
inline

Return last entry.

Definition at line 112 of file SLListBaseI.H.

References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ last() [2/2]

const Foam::SLListBase::link * last ( ) const
inline

Return const access to last entry.

Definition at line 125 of file SLListBaseI.H.

References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ insert()

void insert ( SLListBase::link *  item)

Add at head of list.

Definition at line 34 of file SLListBase.C.

References SLListBase::link::next_.

◆ append()

void append ( SLListBase::link *  item)

Add at tail of list.

Definition at line 56 of file SLListBase.C.

References SLListBase::link::next_.

◆ removeHead()

Foam::SLListBase::link * removeHead ( )

Remove and return head.

Definition at line 77 of file SLListBase.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and SLListBase::link::next_.

Here is the call graph for this function:

◆ remove() [1/2]

Definition at line 103 of file SLListBase.C.

References stdFoam::begin(), stdFoam::end(), SLListBase::iterator::get_node(), SLListBase::iterator::next(), SLListBase::link::next_, and p.

Here is the call graph for this function:

◆ remove() [2/2]

Foam::SLListBase::link * remove ( SLListBase::iterator &  iter)
inline

Definition at line 171 of file SLListBaseI.H.

◆ clear()

void clear ( )
inline

Clear the list.

Definition at line 137 of file SLListBaseI.H.

Referenced by SLListBase::transfer().

Here is the caller graph for this function:

◆ swap()

void swap ( SLListBase &  lst)
inline

Swap the contents of list.

Definition at line 144 of file SLListBaseI.H.

◆ transfer()

void transfer ( SLListBase &  lst)
inline

Transfer the contents of the argument into this list and annul the argument list.

Definition at line 156 of file SLListBaseI.H.

References SLListBase::clear().

Here is the call graph for this function:

◆ begin()

Foam::SLListBase::iterator begin ( )
inline

Iterator to first item in list with non-const access.

Definition at line 249 of file SLListBaseI.H.

References stdFoam::end().

Here is the call graph for this function:

◆ cbegin()

Foam::SLListBase::const_iterator cbegin ( ) const
inline

Iterator to first item in list with const access.

Definition at line 345 of file SLListBaseI.H.

References stdFoam::cend().

Here is the call graph for this function:

◆ crbegin()

const_iterator crbegin ( ) const
delete

No reverse iteration.

◆ end()

const Foam::SLListBase::iterator & end ( )
inline

End of list for iterators.

Definition at line 261 of file SLListBaseI.H.

◆ cend()

const Foam::SLListBase::const_iterator & cend ( ) const
inline

End of list for iterators.

Definition at line 268 of file SLListBaseI.H.

◆ crend()

const const_iterator& crend ( ) const
delete

No reverse iteration.

Friends And Related Function Documentation

◆ iterator

friend class iterator
friend

Definition at line 116 of file SLListBase.H.

◆ const_iterator

friend class const_iterator
friend

Definition at line 119 of file SLListBase.H.


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