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

Intrusive Binary Tree, Root. More...

#include <BalTreeIn.h>

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

Public Member Functions

 BalTreeInRoot ()
 Constructor.
 
virtual ~BalTreeInRoot ()
 Destructor.
 
N * base () const
 
bool check () const override
 
int compare (N const &node1, N const &node2) const
 
int compareKey (N const &node, K key) const
 
N * first () const
 
N * last () const
 
unsigned readLock (bool upgrade) const
 
void readUnlock (unsigned save) const
 
unsigned writeLock (bool upgrade) const
 
void writeUnlock (unsigned save) const
 

Protected Member Functions

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 * 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.
 
void remove (N &node)
 Remove Node from List.
 
void remove (N *node)
 Remove Node from List.
 

Private Types

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

Private Attributes

N * m_base
 Pointer to root node on tree.
 

Friends

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

Detailed Description

template<class R, class N, class K, ContainerThreadSafety s, int n>
class BalTreeInRoot< 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 TreeInRoot:
  • if m_base not nullptr:
    • m_base->m_root == this.
    • m_base->m_parent == nullptr
See also
BalTreeInNode

Note, because base class is a template, we have many forwarding functions to that base to avoid errors and warnings about thing missing.

Member Typedef Documentation

◆ Base

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

◆ Node

template<class R , class N , class K , ContainerThreadSafety s, int n>
class BalTreeInNode< R, N, K, s, n > BalTreeInRoot< R, N, K, s, n >::Node
private

Type of DListIInNode.

◆ Root

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

Type of TreeInRoot.

Constructor & Destructor Documentation

◆ BalTreeInRoot()

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

Constructor.

Starts us as an empty list.

◆ ~BalTreeInRoot()

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

Destructor.

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 * BalTreeInRoot< R, N, K, s, n >::base ( ) const
inline

◆ check()

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

Implements Container< s >.

◆ compare()

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

◆ compareKey()

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

◆ 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 * BalTreeInRoot< R, N, K, s, n >::first ( ) const
inline

◆ last()

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

◆ readLock()

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

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

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

References Container< s >::writeUnlock().

Here is the call graph for this function:

Friends And Related Symbol Documentation

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

template<class R , class N , class K , ContainerThreadSafety s, int n>
friend class BalTreeInNode< 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: