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

Intrusive Doubly Linked List, Node. More...

#include <SortListIn.h>

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

Public Member Functions

 SortListInNode (R &)
 Constructor.
 
 SortListInNode (R *root=nullptr)
 Constructor.
 
 ~SortListInNode ()
 Destructor.
 
void addTo (R &root)
 Add ourself to a list at "natural" position.
 
void addTo (R *root)
 Add ourself to a list at "natural" position.
 
bool check () const override
 
N * next () const
 Return pointer to next node on list.
 
N * prev () const
 Return pointer to previous node on list.
 
unsigned readLock (bool upgrade) const
 
void readUnlock (unsigned save) const
 
void remove ()
 
Rroot () const
 Return pointer to list we are on.
 
unsigned writeLock (bool upgrade) const
 
void writeUnlock (unsigned save) const
 

Private Types

typedef class ListInNode< R, N, s, n > Base
 
typedef Container< s > C
 The type of the Container that we are part of.
 
typedef class SortListInNode< R, N, s, n > Node
 Type of DListIInNode.
 
typedef class SortListInRoot< R, N, s, n > Root
 Type of DListInRoot.
 

Private Member Functions

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.
 
void setRoot (C *root)
 Set our Container.
 
void setRoot (R *root)
 

Private Attributes

N * m_next
 Pointer to next Node in list.
 
Rm_root
 Pointer to list we are on.
 
friend R
 

Friends

class ListInNode< R, N, s, n >
 
class ListInRoot< R, N, s, n >
 
class SortListInRoot< R, N, s, n >
 

Detailed Description

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

Intrusive Doubly Linked List, Node.

Template Parameters
LThe class that will be the owner of the List. Must derive from DListInRoot<R, N, n>
NThe class that will be the nodes of the List. Must derive from DListInNode<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

New:

  • if m_next != nullptr
    • m_root->compare(node, *node.m_next) >= 0
    • m_root->compare(*node.m_next, node) <= 0

From ListIn.h, ListInNode:

  • 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
SortListInRoot

Member Typedef Documentation

◆ Base

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

◆ 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>
class SortListInNode< R, N, s, n > SortListInNode< R, N, s, n >::Node
private

Type of DListIInNode.

◆ Root

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

Type of DListInRoot.

Constructor & Destructor Documentation

◆ SortListInNode() [1/2]

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

Constructor.

Parameters
myRootPointer to list for node to be added to (if not NULL).

◆ SortListInNode() [2/2]

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

Constructor.

Parameters
myRootlist we are to be added to.

◆ ~SortListInNode()

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

Destructor.

Remove us from we are on, if any.

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 )
inlineprotectedinherited

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 )
inlineprotectedinherited

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/4]

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

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/4]

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

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)

◆ addTo() [3/4]

template<class R , class N , ContainerThreadSafety s, int n>
void SortListInNode< R, N, s, n >::addTo ( R & myRoot)

Add ourself to a list at "natural" position.

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

Parameters
myRootList to add to.

◆ addTo() [4/4]

template<class R , class N , ContainerThreadSafety s, int n>
void SortListInNode< R, N, s, n >::addTo ( R * myRoot)

Add ourself to a list at "natural" position.

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

Parameters
myRootList to add to.

◆ addToEnd() [1/2]

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

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 )
inlineprotectedinherited

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 )
inlineprotectedinherited

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 )
inlineprotectedinherited

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 SortListInNode< R, N, s, n >::check ( ) const
overridevirtual
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

Reimplemented from ListInNode< R, N, s, n >.

◆ next()

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

Return pointer to next node on list.

◆ prev()

template<class R , class N , ContainerThreadSafety s, int n>
N * SortListInNode< R, N, s, n >::prev ( ) const
inline

Return pointer to previous node on list.

◆ readLock()

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

References Container< s >::readLock().

Here is the call graph for this function:

◆ readUnlock()

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

References Container< s >::readUnlock().

Here is the call graph for this function:

◆ remove()

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

◆ root()

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

Return pointer to list we are on.

◆ 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)
inlineprotectedinherited

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 SortListInNode< R, N, s, n >::writeLock ( bool upgrade) const
inline

References Container< s >::writeLock().

Here is the call graph for this function:

◆ writeUnlock()

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

References Container< s >::writeUnlock().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ ListInNode< R, N, s, n >

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

◆ ListInRoot< R, N, s, n >

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

◆ SortListInRoot< R, N, s, n >

template<class R , class N , ContainerThreadSafety s, int n>
friend class SortListInRoot< R, N, s, n >
friend

Member Data Documentation

◆ m_next

template<class R , class N , ContainerThreadSafety s, int n>
N* ListInNode< R, N, s, n >::m_next
privateinherited

◆ m_root

◆ R

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

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