Intrusive Containers
Loading...
Searching...
No Matches
ListInRoot< R, N, s, n > Class Template Reference

Intrusive Singly Linked List, List. More...

#include <ListIn.h>

Inheritance diagram for ListInRoot< R, N, s, n >:
Collaboration diagram for ListInRoot< R, N, s, n >:

Protected Member Functions

 ListInRoot ()
 Constructor.
 
 ~ListInRoot ()
 Destructor.
 
void add (N &node, bool upgrade=false)
 Add node to our list, at "natural" point.
 
void add (N *node, bool upgrade=false)
 Add node to our list, at "natural" point.
 
void addFirst (N &node, bool upgrade=false)
 Add node to front of our list.
 
void addFirst (N *node, bool upgrade=false)
 Add node to front of our list.
 
void addLast (N &node, bool upgrade=false)
 Add node to end of our list.
 
void addLast (N *node, bool upgrade=false)
 Add node to end of our list.
 
bool check () const override
 
Nfirst () const
 Return pointer to first Node on list.
 
Nlast () const
 Return pointer to last Node on list.
 
unsigned readLock (bool upgrade) const
 
void readUnlock (unsigned save) const
 
void remove (N &node)
 Remove Node from List.
 
void remove (N *node)
 Remove Node from List.
 
unsigned writeLock (bool upgrade) const
 
void writeUnlock (unsigned save) const
 

Private Types

typedef ListInNode< R, N, s, n > Node
 Type of ListInNode.
 
typedef ListInRoot< R, N, s, n > Root
 Type of ListInRoot.
 

Private Attributes

friend ListInNode< R, N, s, n >
 
Nm_first
 Pointer to first Node on list.
 
Nm_last
 Pointer to last Node on list.
 
friend N
 

Detailed Description

template<class R, class N, ContainerThreadSafety s, int n>
class ListInRoot< R, N, s, n >

Intrusive Singly Linked List, List.

Template Parameters
RThe class that will be the owner of the List. Must derive from ListInRoot<R, N, n>
NThe class that will be the nodes of the List. Must derive from ListInNode<R, N, n>
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Invariant
  • if m_first == nullptr
    • m_last == nullptr
  • if m_first !- nullptr
    • m_last != nullotr
    • m_first->m_root == this
    • m_last->m_root == this
    • m_last->m_next == nullptr
See also
ListInNode

Member Typedef Documentation

◆ Node

template<class R , class N , ContainerThreadSafety s, int n>
ListInNode<R, N, s, n> ListInRoot< R, N, s, n >::Node
private

Type of ListInNode.

◆ Root

template<class R , class N , ContainerThreadSafety s, int n>
ListInRoot<R, N, s, n> ListInRoot< R, N, s, n >::Root
private

Type of ListInRoot.

Constructor & Destructor Documentation

◆ ListInRoot()

template<class R , class N , ContainerThreadSafety s, int n>
ListInRoot< R, N, s, n >::ListInRoot ( )
protected

Constructor.

Starts us as an empty list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.

◆ ~ListInRoot()

template<class R , class N , ContainerThreadSafety s, int n>
ListInRoot< R, N, s, n >::~ListInRoot ( )
protected

Destructor.

Removes all nodes attached to us.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.

Member Function Documentation

◆ add() [1/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::add ( N & node,
bool upgrade = false )
inlineprotected

Add node to our list, at "natural" point.

Note that this is the front for singly linked lists and the end for doubly linked list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add to the list If node is currently on a list (even us) it is removed before being added to the list
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ add() [2/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::add ( N * node,
bool upgrade = false )
inlineprotected

Add node to our list, at "natural" point.

Note that this is the front for singly linked lists and the end for doubly linked lists.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add to the list If node is nulR, Nothing is done. If node is currently on a list (even us) it is removed before being added to the list
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addFirst() [1/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::addFirst ( N & node,
bool upgrade = false )
inlineprotected

Add node to front of our list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add to the list If node is currently on a list (even us) it is removed before being added to the list
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

References ListInNode< R, N, s, n >::m_next, ListInNode< R, N, s, n >::m_root, ListInNode< R, N, s, n >::remove(), and ListInNode< R, N, s, n >::setRoot().

Here is the call graph for this function:

◆ addFirst() [2/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::addFirst ( N * node,
bool upgrade = false )
inlineprotected

Add node to front of our list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add to the list If node is currently on a list (even us) it is removed before being added to the list
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addLast() [1/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::addLast ( N & node,
bool upgrade = false )
inlineprotected

Add node to end of our list.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided
Parameters
nodeThe node to add to the list If node is currently on a list (even us) it is removed before being added to the list
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

References ListInNode< R, N, s, n >::m_next, ListInNode< R, N, s, n >::m_root, ListInNode< R, N, s, n >::remove(), and ListInNode< R, N, s, n >::setRoot().

Here is the call graph for this function:

◆ addLast() [2/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::addLast ( N * node,
bool upgrade = false )
inlineprotected

Add node to end of our list.

Note that this operation is O(n) on list current size. See DListInRoot to make this O(1).

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodeThe node to add to the list If node is currently on a list (even us) it is removed before being added to the list
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ check()

template<class R , class N , ContainerThreadSafety s, int n>
bool ListInRoot< R, N, s, n >::check ( ) const
overrideprotectedvirtual
Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Returns
True if check passes

Implements Container< s >.

Reimplemented in SortListInRoot< R, N, s, n >.

References ListInNode< R, N, s, n >::check(), ListInNode< R, N, s, n >::next(), and ListInNode< R, N, s, n >::root().

Here is the call graph for this function:

◆ first()

template<class R , class N , ContainerThreadSafety s, int n>
N * ListInRoot< R, N, s, n >::first ( ) const
inlineprotected

Return pointer to first Node on list.

References ListInRoot< R, N, s, n >::m_first.

◆ last()

template<class R , class N , ContainerThreadSafety s, int n>
N * ListInRoot< R, N, s, n >::last ( ) const
inlineprotected

Return pointer to last Node on list.

References ListInRoot< R, N, s, n >::m_last.

Referenced by ListInNode< R, N, s, n >::check().

Here is the caller graph for this function:

◆ readLock()

template<class R , class N , ContainerThreadSafety s, int n>
unsigned ListInRoot< R, N, s, n >::readLock ( bool upgrade) const
inlineprotected

References Container< s >::readLock().

Here is the call graph for this function:

◆ readUnlock()

template<class R , class N , ContainerThreadSafety s, int n>
void ListInRoot< R, N, s, n >::readUnlock ( unsigned save) const
inlineprotected

References Container< s >::readUnlock().

Here is the call graph for this function:

◆ remove() [1/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::remove ( N & node)
inlineprotected

Remove Node from List.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodenode to be removed. If node is not on this list, nothing will be done.

References ListInNode< R, N, s, n >::m_root, and ListInNode< R, N, s, n >::remove().

Here is the call graph for this function:

◆ remove() [2/2]

template<class R , class N , ContainerThreadSafety s, int n_>
void ListInRoot< R, N, s, n_ >::remove ( N * node)
inlineprotected

Remove Node from List.

Template Parameters
RThe class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
NThe class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
sThe ContainerThreadSafety value to define the thread safety model of the Container
nA numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
Parameters
nodePointer to node to be removed. If node is null, operation will be ignored. If node is not on this list, nothing will be done.

◆ writeLock()

template<class R , class N , ContainerThreadSafety s, int n>
unsigned ListInRoot< R, N, s, n >::writeLock ( bool upgrade) const
inlineprotected

References Container< s >::writeLock().

Here is the call graph for this function:

◆ writeUnlock()

template<class R , class N , ContainerThreadSafety s, int n>
void ListInRoot< R, N, s, n >::writeUnlock ( unsigned save) const
inlineprotected

References Container< s >::writeUnlock().

Here is the call graph for this function:

Member Data Documentation

◆ ListInNode< R, N, s, n >

template<class R , class N , ContainerThreadSafety s, int n>
friend ListInRoot< R, N, s, n >::ListInNode< R, N, s, n >
private

◆ m_first

template<class R , class N , ContainerThreadSafety s, int n>
N* ListInRoot< R, N, s, n >::m_first
private

Pointer to first Node on list.

Referenced by ListInRoot< R, N, s, n >::first(), and ListInNode< R, N, s, n >::remove().

◆ m_last

template<class R , class N , ContainerThreadSafety s, int n>
N* ListInRoot< R, N, s, n >::m_last
private

Pointer to last Node on list.

Referenced by ListInRoot< R, N, s, n >::last(), and ListInNode< R, N, s, n >::remove().

◆ N

template<class R , class N , ContainerThreadSafety s, int n>
friend ListInRoot< R, N, s, n >::N
private

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