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

Intrusive Doubly Linked List, List. More...

#include <SortListIn.h>

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

Public Member Functions

 SortListInRoot ()
 Constructor.
 
 ~SortListInRoot ()
 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
 
int compare (N const &node1, N const &node2) const
 This member function to be provided by the user to define the sort order.
 
Nfirst () const
 
Nlast () 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 ListInRoot< R, N, s, n > Base
 
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 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

Nm_first
 Pointer to first Node on list.
 
Nm_last
 Pointer to last Node on list.
 
friend N
 

Friends

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

Detailed Description

template<class R, class N, ContainerThreadSafety s, int n>
class SortListInRoot< 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.
Invariant
From ListIn.h, ListInRoot:
  • 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
SortListInNode

Member Typedef Documentation

◆ Base

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

◆ Node

template<class R , class N , ContainerThreadSafety s, int n>
class SortListInNode< R, N, s, n > SortListInRoot< 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 > SortListInRoot< R, N, s, n >::Root
private

Type of DListInRoot.

Constructor & Destructor Documentation

◆ SortListInRoot()

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

Constructor.

Starts us as an empty list.

◆ ~SortListInRoot()

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

Destructor.

Removes all nodes attached to us.

Member Function Documentation

◆ add() [1/4]

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

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

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

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 SortListInRoot< 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(node, 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 SortListInRoot< 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 ListInRoot< R, N, s, n_ >::addFirst ( N & node,
bool upgrade = false )
inlineprotectedinherited

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

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

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

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

◆ compare()

template<class R , class N , ContainerThreadSafety s, int n>
int SortListInRoot< 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 * SortListInRoot< R, N, s, n >::first ( ) const
inline

◆ last()

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

◆ readLock()

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

◆ remove() [1/2]

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

◆ remove() [2/2]

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

◆ writeLock()

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

◆ SortListInNode< R, N, s, n >

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

Member Data Documentation

◆ m_first

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

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
privateinherited

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
privateinherited

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