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

Intrusive Doubly Linked List, List. More...

#include <SortDListIn.h>

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

Public Member Functions

 SortDListInRoot ()
 Constructor.
 
 ~SortDListInRoot ()
 Destructor.
 
void add (N &node)
 Add node to list based on sorting function in Root.
 
void add (N *node)
 Add node to our list, at "natural" point.
 
bool check () const override
 Check a DListInRoot and the list connected.
 
int compare (N const &node1, N const &node2) const
 This member function to be provided by the user to define the sort order.
 
N * first () const
 
N * last () const
 
unsigned readLock (bool upgrade) const
 
void readUnlock (unsigned save) const
 
void remove (N &node)
 
void remove (N *node)
 
unsigned writeLock (bool upgrade) const
 
void writeUnlock (unsigned save) const
 

Private Types

typedef class DListInRoot< R, N, s, n > Base
 
typedef class SortDListInNode< R, N, s, n > Node
 Type of DListIInNode.
 
typedef class SortDListInRoot< R, N, s, n > Root
 Type of DListInRoot.
 

Private Member Functions

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.
 

Private Attributes

N * m_first
 Pointer to first node on list.
 
N * m_last
 Pointer to last node on list.
 

Friends

class DListInNode< R, N, s, n >
 
class DListInRoot< R, N, s, n >
 
class SortDListInNode< R, N, s, n >
 

Detailed Description

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

Intrusive Doubly Linked List, List.

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.
Warning
The Sorted Lists are new additions and not fully tested
See also
SortDListInNode

Member Typedef Documentation

◆ Base

template<class R , class N , ContainerThreadSafety s, int n>
class DListInRoot< R, N, s, n > SortDListInRoot< R, N, s, n >::Base
private

◆ Node

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

Type of DListIInNode.

◆ Root

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

Type of DListInRoot.

Constructor & Destructor Documentation

◆ SortDListInRoot()

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

Constructor.

Starts us as an empty list.

◆ ~SortDListInRoot()

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

Destructor.

Removes all nodes attached to us.

Member Function Documentation

◆ add() [1/4]

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

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.

If node is currently on a list (even us) it is removed before being added to the 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
upgradeSet True if caller has an upgradable Read Lock (Used by SortDListInNode)

◆ add() [2/4]

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

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)

◆ add() [3/4]

template<class R , class N , ContainerThreadSafety s, int n_>
void SortDListInRoot< R, N, s, n_ >::add ( N & node)
inline

Add node to list based on sorting function in Root.

The node is placed such that compare(listnode, this) will be positive (or zero) for all nodes before this one, and negative for nodes after (or zero if they were added after us)

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

◆ add() [4/4]

template<class R , class N , ContainerThreadSafety s, int n_>
void SortDListInRoot< R, N, s, n_ >::add ( N * node)
inline

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.

Parameters
nodeThe node to add to the list If node is null, Nothing is done. If node is currently on a list (even us) it is removed before being added to the list

◆ addFirst() [1/2]

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

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

◆ addFirst() [2/2]

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

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

◆ addLast() [1/2]

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

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

◆ addLast() [2/2]

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

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

◆ check()

template<class R , class N , ContainerThreadSafety s, int n>
bool SortDListInRoot< R, N, s, n >::check ( ) const
overridevirtual

Check a DListInRoot and the list connected.

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 DListInRoot< R, N, s, n >.

◆ compare()

template<class R , class N , ContainerThreadSafety s, int n>
int SortDListInRoot< R, N, s, n >::compare ( N const & node1,
N const & node2 ) const

This member function to be provided by the user to define the sort order.

Parameters
node1
node2
Returns
<0 if node1 should be before node2, >0 if after, 0 if they compare equal, new nodes will be added after.

Sort order for nodes on the list should not change after they are added.

◆ first()

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

◆ last()

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

◆ readLock()

template<class R , class N , ContainerThreadSafety s, int n>
unsigned SortDListInRoot< 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 SortDListInRoot< R, N, s, n >::readUnlock ( unsigned save) const
inline

◆ remove() [1/2]

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

◆ remove() [2/2]

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

◆ writeLock()

template<class R , class N , ContainerThreadSafety s, int n>
unsigned SortDListInRoot< 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 SortDListInRoot< 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

◆ DListInNode< R, N, s, n >

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

◆ DListInRoot< R, N, s, n >

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

◆ SortDListInNode< R, N, s, n >

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

Member Data Documentation

◆ m_first

template<class R , class N , ContainerThreadSafety s, int n>
N* DListInRoot< R, N, s, n >::m_first
privateinherited

Pointer to first node on list.

Referenced by DListInRoot< R, N, s, n >::first().

◆ m_last

template<class R , class N , ContainerThreadSafety s, int n>
N* DListInRoot< R, N, s, n >::m_last
privateinherited

Pointer to last node on list.

Referenced by DListInRoot< R, N, s, n >::last().


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