Intrusive Containers
|
Intrusive Binary Tree, Node. More...
#include <BalTreeIn.h>
Protected Member Functions | |
BalTreeInNode () | |
Constructor. | |
virtual | ~BalTreeInNode () |
Destructor. | |
void | addTo (R &root) |
Add ourself to a tree. | |
void | addTo (R *root) |
Add ourself to a tree. | |
bool | check () const override |
N * | left () const |
N * | next () const |
N * | parent () const |
N * | prev () const |
unsigned | readLock (bool upgrade) const |
void | readUnlock (unsigned save) const |
void | rebalance () override=0 |
Hook to allow Balanced trees to rebalance from current node, just changed. | |
virtual void | remove () |
Remove node from whatever tree it is on, if it is on a tree. | |
void | resort () |
N * | right () const |
R * | root () const |
N * | rotateLeft () |
Balance tree with a Left Rotate. | |
N * | rotateRight () |
Balance Tree with a Right Rotate. | |
void | setRoot (C *root) |
Set our Container. | |
void | setRoot (R *root) |
unsigned | writeLock (bool upgrade) const |
void | writeUnlock (unsigned save) const |
Private Types | |
typedef class TreeInNode< R, N, K, s, n > | Base |
typedef Container< s > | C |
The type of the Container that we are part of. | |
typedef class BalTreeInNode< R, N, K, s, n > | Node |
Type of Node. | |
typedef class BalTreeInRoot< R, N, K, s, n > | Root |
Type of Root. | |
Private Attributes | |
N * | m_left |
Pointer to left (lesser) child node on tree. | |
N * | m_parent |
Pointer to parent node on tree. | |
N * | m_right |
Pointer to right (greater) child node on tree. | |
R * | m_root |
Pointer to tree we are on. | |
Friends | |
class | BalTreeInRoot< R, N, K, s, n > |
Intrusive Binary Tree, Node.
R | The class that will be the owner of the List. Must derive from TreeInRoot<R, N, K, n> |
N | The class that will be the nodes of the List. Must derive from TreeInNode<R, N, K, n> |
K | The class defining the Key used to lookup Nodes in the tree. |
s | The ContainerThreadSafety value to define the thread safety model of the Container |
n | A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided. |
|
private |
|
privateinherited |
The type of the Container that we are part of.
|
private |
Type of Node.
|
private |
Type of Root.
|
protected |
Constructor.
|
protectedvirtual |
Destructor.
|
protectedinherited |
Add ourself to a tree.
myroot | Tree to add to. |
|
protectedinherited |
Add ourself to a tree.
myroot | Tree to add to. |
|
inlineoverrideprotectedvirtual |
Implements ContainerNode< s >.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
overrideprotectedpure virtual |
Hook to allow Balanced trees to rebalance from current node, just changed.
Reimplemented from TreeInNode< R, N, K, s, n >.
Implemented in AATreeInNode< R, N, K, s, n >.
|
inlineprotectedvirtualinherited |
Remove node from whatever tree it is on, if it is on a tree.
Delete Node N Simple Cases, Not both childern (x is empty link) P P P P P P | => x | => | | => | N N L N R x x / x \ L R Rebalance at P More Complicated, as we have both childern More Complicated Special Case P P P P | => | | => | N D N L / \ / \ / \ / \ L R L R L R A R \ \ / x A A A \ \ B B \ \ D C / x C Rebalance at B. D might be L if it had no right child in which case rebalance at L L < A < B < C < D < N < R Link to P either a left or right, or Root if P is NULL. x indicates NULL links
|
protectedinherited |
|
inlineprotected |
|
inlineprotected |
|
protected |
Balance tree with a Left Rotate.
Given A < L < B < R < C Either P < A, or C < P (A, B, C are subtrees, relations apply to ALL members in that subtree) P P | | R Rotate Right => L / \ <= Rotate Left / \ L C A R / \ / \ A B B C
Rotate Right moves the current node to the right of the node on its left Rotate Left moves the current to to the left of the node on its right.
Caller should have an upgradable read-lock
Anyone walking the tree should have a readLock that we will wait to be released.
|
protected |
|
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().
|
inlineprotectedinherited |
References TreeInNode< R, N, K, s, n >::m_root, TreeInNode< R, N, K, s, n >::root(), and ContainerNode< s >::setRoot().
|
inlineprotected |
|
inlineprotected |
|
friend |
|
privateinherited |
Pointer to left (lesser) child node on tree.
Referenced by TreeInNode< R, N, K, s, n >::left().
|
privateinherited |
Pointer to parent node on tree.
Referenced by TreeInNode< R, N, K, s, n >::parent().
|
privateinherited |
Pointer to right (greater) child node on tree.
Referenced by TreeInNode< R, N, K, s, n >::right().
|
privateinherited |
Pointer to tree we are on.
Referenced by TreeInNode< R, N, K, s, n >::root(), and TreeInNode< R, N, K, s, n >::setRoot().