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

Intrusive Binary Tree, Root. More...

#include <AATreeIn.h>

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

Public Member Functions

bool check () const override
 
unsigned readLock (bool upgrade) const
 
unsigned writeLock (bool upgrade) const
 

Protected Member Functions

 AATreeInRoot ()
 Constructor.
 
virtual ~AATreeInRoot ()
 Destructor.
 
virtual void add (N &node)
 Add node to our tree, note trees are sorted by the compare member function which needs to be implemented by the user.
 
void add (N *node)
 Add node to our tree.
 
N * base () const
 
int compare (N const &node1, N const &node2) const
 
int compareKey (N const &node, K key) const
 
N * find (K key) const
 find a node
 
N * findMinus (K key) const
 find a node, or the node that would be just lower than this node
 
N * findPlus (K key) const
 find a node, r the node that would be just above this node.
 
N * first () const
 
N * last () const
 
unsigned readLock () const
 
void readUnlock (unsigned save) const
 
void remove (N &node)
 Remove Node from List.
 
void remove (N *node)
 Remove Node from List.
 
unsigned writeLock () const
 
void writeUnlock (unsigned save) const
 

Private Types

typedef class BalTreeInRoot< R, N, K, s, n > Base
 
typedef class AATreeInNode< R, N, K, s, n > Node
 Type of DListIInNode.
 
typedef class AATreeInRoot< R, N, K, s, n > Root
 Type of TreeInRoot.
 

Private Attributes

N * m_base
 Pointer to root node on tree.
 

Friends

class AATreeInNode< R, N, K, s, n >
 

Detailed Description

template<class R, class N, class K, ContainerThreadSafety s, int n>
class AATreeInRoot< R, N, K, s, n >

Intrusive Binary Tree, Root.

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>
KThe class defining the Key used to lookup Nodes in the tree.
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.
Invariant

From TreeIn:

  • if m_base != nullptr:
    • m_base-> m_root == this
    • m_base-> m_parent == nullptr

See also
TreeInNode

Member Typedef Documentation

◆ Base

template<class R , class N , class K , ContainerThreadSafety s, int n>
class BalTreeInRoot< R, N, K, s, n > AATreeInRoot< R, N, K, s, n >::Base
private

◆ Node

template<class R , class N , class K , ContainerThreadSafety s, int n>
class AATreeInNode< R, N, K, s, n > AATreeInRoot< R, N, K, s, n >::Node
private

Type of DListIInNode.

◆ Root

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

Type of TreeInRoot.

Constructor & Destructor Documentation

◆ AATreeInRoot()

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

Constructor.

Starts us as an empty list.

◆ ~AATreeInRoot()

template<class R , class N , class K , ContainerThreadSafety s, int n>
AATreeInRoot< R, N, K, s, n >::~AATreeInRoot ( )
protectedvirtual

Destructor.

Removes all nodes attached to us.

Doesn't actually call remove on every node to avoid possible unneeded rebalencing, just manually unlinks all nodes.

Member Function Documentation

◆ add() [1/2]

template<class R , class N , class K , ContainerThreadSafety s, int n>
void TreeInRoot< R, N, K, s, n >::add ( N & node)
inlineprotectedvirtualinherited

Add node to our tree, note trees are sorted by the compare member function which needs to be implemented by the user.

Parameters
nodeThe node to add to the list If node is currently on a different list it is removed before being added to the list.

If node is on the requested list, do nothing. If trying to change value and position, use resort

◆ add() [2/2]

template<class R , class N , class K , ContainerThreadSafety s, int n_>
void TreeInRoot< R, N, K, s, n_ >::add ( N * node)
inlineprotectedinherited

Add node to our tree.

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

◆ base()

template<class R , class N , class K , ContainerThreadSafety s, int n>
N * AATreeInRoot< R, N, K, s, n >::base ( ) const
inlineprotected

◆ check()

template<class R , class N , class K , ContainerThreadSafety s, int n>
bool BalTreeInRoot< R, N, K, s, n >::check ( ) const
inlineoverridevirtualinherited

Implements Container< s >.

◆ compare()

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

◆ compareKey()

template<class R , class N , class K , ContainerThreadSafety s, int n>
int AATreeInRoot< R, N, K, s, n >::compareKey ( N const & node,
K key ) const
inlineprotected

◆ find()

template<class R , class N , class K , ContainerThreadSafety s, int n>
N * TreeInRoot< R, N, K, s, n >::find ( K key) const
protectedinherited

find a node

◆ findMinus()

template<class R , class N , class K , ContainerThreadSafety s, int n>
N * TreeInRoot< R, N, K, s, n >::findMinus ( K key) const
protectedinherited

find a node, or the node that would be just lower than this node

◆ findPlus()

template<class R , class N , class K , ContainerThreadSafety s, int n>
N * TreeInRoot< R, N, K, s, n >::findPlus ( K key) const
protectedinherited

find a node, r the node that would be just above this node.

◆ first()

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

◆ last()

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

◆ readLock() [1/2]

template<class R , class N , class K , ContainerThreadSafety s, int n>
unsigned AATreeInRoot< R, N, K, s, n >::readLock ( ) const
inlineprotected

References Container< s >::readLock().

Here is the call graph for this function:

◆ readLock() [2/2]

template<class R , class N , class K , ContainerThreadSafety s, int n>
unsigned BalTreeInRoot< R, N, K, s, n >::readLock ( bool upgrade) const
inlineinherited

References Container< s >::readLock().

Here is the call graph for this function:

◆ readUnlock()

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

◆ remove() [1/2]

template<class R , class N , class K , ContainerThreadSafety s, int n>
void TreeInRoot< R, N, K, s, n >::remove ( N & node)
inlineprotectedinherited

Remove Node from List.

Parameters
nodenode to be removed. If node is not on this list, nothing will be done.

◆ remove() [2/2]

template<class R , class N , class K , ContainerThreadSafety s, int n_>
void TreeInRoot< R, N, K, s, n_ >::remove ( N * node)
inlineprotectedinherited

Remove Node from List.

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() [1/2]

template<class R , class N , class K , ContainerThreadSafety s, int n>
unsigned AATreeInRoot< R, N, K, s, n >::writeLock ( ) const
inlineprotected

References Container< s >::writeLock().

Here is the call graph for this function:

◆ writeLock() [2/2]

template<class R , class N , class K , ContainerThreadSafety s, int n>
unsigned BalTreeInRoot< R, N, K, s, n >::writeLock ( bool upgrade) const
inlineinherited

References Container< s >::writeLock().

Here is the call graph for this function:

◆ writeUnlock()

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

References Container< s >::writeUnlock().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ AATreeInNode< R, N, K, s, n >

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

Member Data Documentation

◆ m_base

template<class R , class N , class K , ContainerThreadSafety s, int n>
N* TreeInRoot< R, N, K, s, n >::m_base
privateinherited

Pointer to root node on tree.

Referenced by TreeInRoot< R, N, K, s, n >::base().


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