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

Intrusive Singly Linked List, Node. More...

#include <ListIn.h>

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

Protected Member Functions

 ListInNode (R &myRoot)
 Constructor.
 
 ListInNode (R *myRoot=nullptr)
 Constructor.
 
 ~ListInNode ()
 Destructor.
 
void addAfter (N &myNode, bool upgrade=false)
 Add ourself to a list after another node.
 
void addAfter (N *myNode, bool upgrade=false)
 Add ourself to a list after another node.
 
void addTo (R &myRoot, bool upgrade=false)
 Add ourself to a list at "natural" postion.
 
void addTo (R *myRoot, bool upgrade=false)
 Add ourself to a list at "natural" postion.
 
void addToEnd (R &myRoot, bool upgrade=false)
 Add ourselfs to the end of a list.
 
void addToEnd (R *myRoot, bool upgrade=false)
 Add ourselves to the End of a list.
 
void addToFront (R &myRoot, bool upgrade=false)
 Add ourselfs to the front of a list.
 
void addToFront (R *myRoot, bool upgrade=false)
 Add ourselfs to the front of a list.
 
bool check () const override
 
N * next () const
 Return pointer to next Node on List.
 
unsigned readLock (bool upgrade) const
 
void readUnlock (unsigned save) const
 
void remove ()
 Remove node from whatever list it is on, if it is on a list.
 
Rroot () const
 Return pointer to List we are on.
 
void setRoot (C *root)
 Set our Container.
 
void setRoot (R *root)
 
unsigned writeLock (bool upgrade) const
 
void writeUnlock (unsigned save) const
 

Private Types

typedef Container< s > C
 The type of the Container that we are part of.
 
typedef ListInNode< R, N, s, n > Node
 Type of ListInNode.
 
typedef ListInRoot< R, N, s, n > Root
 Type of ListInRoot.
 

Private Attributes

friend ListInRoot< R, N, s, n >
 
N * m_next
 Pointer to next Node in list.
 
Rm_root
 Pointer to list we are on.
 
friend R
 

Detailed Description

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

Intrusive Singly Linked List, Node.

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_root == nullptr
    • m_nest == nullptr
  • if m_next == nullptr
    • m_root->m_last = this;
  • if m_next != nullptr
    • m_next->m_root == m_root
    • m_next != m_root->m_first

Last Criteria is closet expression to the fact that root.m_first points to a node that other node points to as its m_next

See also
ListInRoot

Member Typedef Documentation

◆ C

template<ContainerThreadSafety s>
Container<s> ContainerNode< s >::C
privateinherited

The type of the Container that we are part of.

◆ Node

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

Type of ListInNode.

◆ Root

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

Type of ListInRoot.

Constructor & Destructor Documentation

◆ ListInNode() [1/2]

template<class R , class N , ContainerThreadSafety s, int n>
ListInNode< R, N, s, n >::ListInNode ( R & myRoot)
protected

Constructor.

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
myRootlist we are to be added to.

References ListInNode< R, N, s, n >::addTo().

Here is the call graph for this function:

◆ ListInNode() [2/2]

template<class R , class N , ContainerThreadSafety s, int n>
ListInNode< R, N, s, n >::ListInNode ( R * myRoot = nullptr)
protected

Constructor.

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
myRootPointer to list for node to be added to (if not NULL).

References ListInNode< R, N, s, n >::addTo().

Here is the call graph for this function:

◆ ~ListInNode()

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

Destructor.

Remove us from we are on, if any.

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

◆ addAfter() [1/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addAfter ( N & node,
bool upgrade = false )
inlineprotected

Add ourself to a list after another node.

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 ourself after. If node is not on a list, do nothing.
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 >::writeLock(), and ListInNode< R, N, s, n >::writeUnlock().

Here is the call graph for this function:

◆ addAfter() [2/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addAfter ( N * node,
bool upgrade = false )
inlineprotected

Add ourself to a list after another node.

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 ourself after. If Node is NULL, or not on a list, do nothing.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addTo() [1/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addTo ( R & myRoot,
bool upgrade = false )
protected

Add ourself to a list at "natural" postion.

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
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

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

Here is the caller graph for this function:

◆ addTo() [2/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addTo ( R * myRoot,
bool upgrade = false )
protected

Add ourself to a list at "natural" postion.

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
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToEnd() [1/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addToEnd ( R & myRoot,
bool upgrade = false )
inlineprotected

Add ourselfs to the end of a 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
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToEnd() [2/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addToEnd ( R * myRoot,
bool upgrade = false )
inlineprotected

Add ourselves to the End of a 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
myRootList to add to. If NULL, just remove from all lists.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToFront() [1/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addToFront ( R & myRoot,
bool upgrade = false )
inlineprotected

Add ourselfs to the front of a 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
myRootList to add to.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ addToFront() [2/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::addToFront ( R * myRoot,
bool upgrade = false )
inlineprotected

Add ourselfs to the front of a 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
myRootList to add to. If NULL, just remove from all lists.
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ check()

template<class R , class N , ContainerThreadSafety s, int n>
bool ListInNode< 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 ContainerNode< s >.

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

References ListInRoot< R, N, s, n >::last(), and ListInNode< R, N, s, n >::root().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ next()

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

Return pointer to next Node on List.

References ListInNode< R, N, s, n >::m_next.

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

Here is the caller graph for this function:

◆ readLock()

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

References ContainerNode< s >::readLock().

Here is the call graph for this function:

◆ readUnlock()

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

References ContainerNode< s >::readUnlock().

Here is the call graph for this function:

◆ remove()

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::remove ( )
inlineprotected

Remove node from whatever list it is on, if it is on a 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.

References ListInRoot< R, N, s, n >::m_first, ListInRoot< R, N, s, n >::m_last, and ListInNode< R, N, s, n >::m_next.

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

Here is the caller graph for this function:

◆ root()

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

Return pointer to List we are on.

References ListInNode< R, N, s, n >::m_root.

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

Here is the caller graph for this function:

◆ setRoot() [1/2]

template<ContainerThreadSafety s>
void ContainerNode< s >::setRoot ( C * root)
inlineprotectedinherited

Set our Container.

Used to allow to Node to record what Container it is in. Used only if safety method need resources from the Container, like a Mutex

If an operation changes the root of a node, then it needs to save the original root to exit the critical section on that container that it entered before the operation.

Referenced by ContainerNode< s >::ContainerNode(), DListInNode< R, N, s, n >::setRoot(), ListInNode< R, N, s, n >::setRoot(), and TreeInNode< R, N, K, s, n >::setRoot().

Here is the caller graph for this function:

◆ setRoot() [2/2]

template<class R , class N , ContainerThreadSafety s, int n>
void ListInNode< R, N, s, n >::setRoot ( R * root)
inlineprotected

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

Referenced by ListInRoot< R, N, s, n >::addFirst(), and ListInRoot< R, N, s, n >::addLast().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeLock()

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

References ContainerNode< s >::writeLock().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeUnlock()

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

References ContainerNode< s >::writeUnlock().

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

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ListInRoot< R, N, s, n >

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

◆ m_next

◆ m_root

◆ R

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

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