55template <
class R,
class N,
class K, ContainerThreadSafety s,
int n>
57 N
const* me =
static_cast<N const*
>(
this);
58 unsigned save = readLock(
false);
60 Root* myroot = root();
61 if (parent() ==
nullptr) {
62 TREEIN_ASSERT(
static_cast<Root*
>(root())->m_base == me);
64 Node* myparent = parent();
65 TREEIN_ASSERT(myparent->left() == me || myparent->right() == me);
66 TREEIN_ASSERT(myparent->root() == root());
70 Node* myleft = left();
71 TREEIN_ASSERT(myleft->m_parent == me);
72 TREEIN_ASSERT(myroot->compare(*me, *left()) <= 0);
73 TREEIN_ASSERT(myroot->compare(*left(), *me) >= 0);
77 Node* myright = right();
78 TREEIN_ASSERT(myright->parent() == me);
79 TREEIN_ASSERT(myroot->compare(*me, *right()) >= 0);
80 TREEIN_ASSERT(myroot->compare(*right(), *me) <= 0);
83 TREEIN_ASSERT(parent() ==
nullptr);
84 TREEIN_ASSERT(left() ==
nullptr);
85 TREEIN_ASSERT(right() ==
nullptr);
92template <
class R,
class N,
class K, ContainerThreadSafety s,
int n>
94 R
const* me =
static_cast<R const*
>(
this);
95 unsigned save = readLock(
false);
97 Node* node =
static_cast<Node*
>(base());
98 TREEIN_ASSERT(node->root() == me);
99 TREEIN_ASSERT(node->parent() ==
nullptr);
115template <
class R,
class N,
class K, ContainerThreadSafety s,
int n>
124template <
class R,
class N,
class K, ContainerThreadSafety s,
int n>
132template <
class R,
class N,
class K, ContainerThreadSafety s,
int n>
140template <
class R,
class N,
class K, ContainerThreadSafety s,
int n>
174template<
class R,
class N,
class K, ContainerThreadSafety s,
int n>
176 unsigned save = writeLock(
true);
178 N* pivot = this->Base::m_right;
179 Node* pivot_ = pivot;
180 N* me =
static_cast<N*
>(
this);
183 this->Base::m_right = pivot->Base::m_left;
184 if(this->Base::m_right){
185 this->Base::m_right->Base::m_parent = me;
189 pivot_->Base::m_parent = this->Base::m_parent;
190 if(pivot_->Base::m_parent) {
191 if(pivot->Base::m_parent->Base::m_left ==
this) {
192 pivot_->Base::m_parent->Base::m_left = pivot;
194 pivot_->Base::m_parent->Base::m_right = pivot;
197 Root* root = pivot_->Base::m_root;
198 root->m_base = pivot;
202 pivot_->Base::m_left = me;
203 this->Base::m_parent = pivot;
215template<
class R,
class N,
class K, ContainerThreadSafety s,
int n>
217 unsigned save = writeLock(
true);
219 N* pivot = this->Base::m_left;
220 Node* pivot_ = pivot;
221 N* me =
static_cast<N*
>(
this);
224 this->Base::m_left = pivot->Base::m_right;
225 if(this->Base::m_left) {
226 this->Base::m_left->Base::m_parent = me;
230 pivot_->Base::m_parent = this->Base::m_parent;
231 if(pivot->Base::m_parent) {
232 if(pivot->Base::m_parent->Base::m_left ==
this) {
233 pivot->Base::m_parent->Base::m_left = pivot;
235 pivot->Base::m_parent->Base::m_right = pivot;
238 Root* root = pivot_->Base::m_root;
239 root->m_base = pivot;
242 pivot->Base::m_right = me;
243 this->Base::m_parent = pivot;
Intrusive Binary Tree (balenced).
Intrusive Binary Tree (unbalenced), Implementation.
BalTreeInNode()
Constructor.
Definition BalTreeIn.hpp:133
virtual ~BalTreeInNode()
Destructor.
Definition BalTreeIn.hpp:141
N * rotateLeft()
Balance tree with a Left Rotate.
Definition BalTreeIn.hpp:175
N * rotateRight()
Balance Tree with a Right Rotate.
Definition BalTreeIn.hpp:216
class BalTreeInNode< R, N, K, s, n > Node
Type of Node.
Definition BalTreeIn.h:226
class BalTreeInRoot< R, N, K, s, n > Root
Type of Root.
Definition BalTreeIn.h:225
bool check() const override
Definition BalTreeIn.hpp:106
bool check() const override
Definition BalTreeIn.hpp:107
virtual ~BalTreeInRoot()
Destructor.
Definition BalTreeIn.hpp:125
BalTreeInRoot()
Constructor.
Definition BalTreeIn.hpp:116