DLListBase Class Reference

Base for doubly-linked lists. More...

Classes

class  const_iterator
 A primitive const node iterator (bidirectional). More...
 
class  iterator
 A primitive non-const node iterator. More...
 
struct  link
 The structure for a doubly-linked storage node. More...
 

Public Member Functions

 DLListBase ()=default
 Default construct. More...
 
 DLListBase (const DLListBase &)=delete
 No copy construct. More...
 
void operator= (const DLListBase &)=delete
 No copy assignment. More...
 
 ~DLListBase ()=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...
 
linkfirst ()
 Return first entry. More...
 
const linkfirst () const
 Return const access to first entry. More...
 
linklast ()
 Return last entry. More...
 
const linklast () const
 Return const access to last entry. More...
 
void prepend (link *item)
 Add at front of list. More...
 
void append (link *item)
 Add at back of list. More...
 
bool swapUp (link *item)
 Swap this element with the one above unless it is at the top. More...
 
bool swapDown (link *item)
 Swap this element with the one below unless it is at the bottom. More...
 
linkremoveHead ()
 Remove and return first entry. More...
 
linkremove (link *item)
 Remove and return element. More...
 
linkremove (iterator &iter)
 Remove and return element specified by iterator. More...
 
linkreplace (link *oldLink, link *newLink)
 Replace oldLink with newLink and return element. More...
 
linkreplace (iterator &oldIter, link *newitem)
 Replace oldIter with newItem and return element. More...
 
void clear ()
 Clear the list. More...
 
void swap (DLListBase &lst)
 Swap the contents of the list. More...
 
void transfer (DLListBase &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
 Iterator to last item in list with const access. More...
 
const iteratorend ()
 End of list for iterators. More...
 
const const_iteratorcend () const
 End of list for iterators. More...
 
const const_iteratorcrend () const
 End of list for reverse iterators. 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 ()
 Factory method to return an iterator reverse end. More...
 

Friends

class iterator
 
class const_iterator
 

Detailed Description

Base for doubly-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 DLListBase.H.

Constructor & Destructor Documentation

◆ DLListBase() [1/2]

DLListBase ( )
default

Default construct.

◆ DLListBase() [2/2]

DLListBase ( const DLListBase )
delete

No copy construct.

◆ ~DLListBase()

~DLListBase ( )
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 DLListBase iterator.

Definition at line 35 of file DLListBaseI.H.

References Foam::nullObjectPtr.

◆ iterator_rend()

const IteratorType & iterator_rend
inlinestaticprotected

Factory method to return an iterator reverse end.

Simply reinterprets a NullObject as a DLListBase iterator.

Definition at line 42 of file DLListBaseI.H.

References Foam::nullObjectPtr.

◆ iterator_first()

IteratorType iterator_first
inlineprotected

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

Removes constness which the caller promises to manage.

Definition at line 49 of file DLListBaseI.H.

◆ iterator_last()

IteratorType iterator_last
inlineprotected

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

Removes constness which the caller promises to manage.

Definition at line 64 of file DLListBaseI.H.

◆ operator=()

void operator= ( const DLListBase )
delete

No copy assignment.

◆ size()

Foam::label size ( ) const
inlinenoexcept

The number of elements in list.

Definition at line 114 of file DLListBaseI.H.

Referenced by DLListBase::begin(), DLListBase::cbegin(), and DLListBase::crbegin().

Here is the caller graph for this function:

◆ empty()

bool empty ( ) const
inlinenoexcept

True if the list is empty.

Definition at line 120 of file DLListBaseI.H.

◆ first() [1/2]

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

Return first entry.

Definition at line 127 of file DLListBaseI.H.

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

Here is the call graph for this function:

◆ first() [2/2]

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

Return const access to first entry.

Definition at line 140 of file DLListBaseI.H.

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

Here is the call graph for this function:

◆ last() [1/2]

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

Return last entry.

Definition at line 153 of file DLListBaseI.H.

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

Here is the call graph for this function:

◆ last() [2/2]

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

Return const access to last entry.

Definition at line 166 of file DLListBaseI.H.

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

Here is the call graph for this function:

◆ prepend()

void prepend ( DLListBase::link item)

Add at front of list.

Definition at line 34 of file DLListBase.C.

References DLListBase::link::next_, and DLListBase::link::prev_.

◆ append()

void append ( DLListBase::link item)

Add at back of list.

Definition at line 59 of file DLListBase.C.

References DLListBase::link::next_, and DLListBase::link::prev_.

◆ swapUp()

bool swapUp ( DLListBase::link a)

Swap this element with the one above unless it is at the top.

Definition at line 84 of file DLListBase.C.

References DLListBase::link::next_, and DLListBase::link::prev_.

◆ swapDown()

bool swapDown ( DLListBase::link a)

Swap this element with the one below unless it is at the bottom.

Definition at line 123 of file DLListBase.C.

References DLListBase::link::next_, and DLListBase::link::prev_.

◆ removeHead()

Foam::DLListBase::link * removeHead ( )

Remove and return first entry.

Definition at line 162 of file DLListBase.C.

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

Here is the call graph for this function:

◆ remove() [1/2]

Remove and return element.

Definition at line 186 of file DLListBase.C.

References DLListBase::link::deregister(), DLListBase::link::next_, and DLListBase::link::prev_.

Here is the call graph for this function:

◆ remove() [2/2]

Foam::DLListBase::link * remove ( DLListBase::iterator iter)
inline

Remove and return element specified by iterator.

Definition at line 215 of file DLListBaseI.H.

◆ replace() [1/2]

Foam::DLListBase::link * replace ( DLListBase::link oldLink,
DLListBase::link newLink 
)

Replace oldLink with newLink and return element.

Definition at line 218 of file DLListBase.C.

References DLListBase::link::deregister(), DLListBase::link::next_, and DLListBase::link::prev_.

Here is the call graph for this function:

◆ replace() [2/2]

Foam::DLListBase::link * replace ( DLListBase::iterator oldIter,
DLListBase::link newItem 
)
inline

Replace oldIter with newItem and return element.

Definition at line 225 of file DLListBaseI.H.

◆ clear()

void clear ( )
inline

Clear the list.

Definition at line 178 of file DLListBaseI.H.

Referenced by DLListBase::transfer().

Here is the caller graph for this function:

◆ swap()

void swap ( DLListBase lst)
inline

Swap the contents of the list.

Definition at line 186 of file DLListBaseI.H.

◆ transfer()

void transfer ( DLListBase lst)
inline

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

Definition at line 199 of file DLListBaseI.H.

References DLListBase::clear().

Here is the call graph for this function:

◆ begin()

Foam::DLListBase::iterator begin ( )
inline

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

Definition at line 326 of file DLListBaseI.H.

References DLListBase::end(), and DLListBase::size().

Here is the call graph for this function:

◆ cbegin()

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

Iterator to first item in list with const access.

Definition at line 424 of file DLListBaseI.H.

References DLListBase::cend(), and DLListBase::size().

Here is the call graph for this function:

◆ crbegin()

Foam::DLListBase::const_iterator crbegin ( ) const
inline

Iterator to last item in list with const access.

Note that this is not a const_reverse_iterator, this is the responsibility of any derived classes.

Definition at line 436 of file DLListBaseI.H.

References DLListBase::crend(), and DLListBase::size().

Here is the call graph for this function:

◆ end()

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

End of list for iterators.

Definition at line 80 of file DLListBaseI.H.

Referenced by DLListBase::begin().

Here is the caller graph for this function:

◆ cend()

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

End of list for iterators.

Definition at line 87 of file DLListBaseI.H.

Referenced by DLListBase::cbegin().

Here is the caller graph for this function:

◆ crend()

const Foam::DLListBase::const_iterator & crend ( ) const
inline

End of list for reverse iterators.

Definition at line 94 of file DLListBaseI.H.

Referenced by DLListBase::crbegin().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ iterator

friend class iterator
friend

Definition at line 129 of file DLListBase.H.

◆ const_iterator

friend class const_iterator
friend

Definition at line 132 of file DLListBase.H.


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