41 #define TREEIN_CHECK 1
45 #define assert configASSERT
62 N
const* me =
static_cast<N const*
>(
this);
66 assert(static_cast<Root*>(root_)->base_ == me);
68 Node* myparent =
static_cast<Node*
>(parent_);
69 assert(myparent->left_ == me || myparent->right_ == me);
70 assert(myparent->root_ == root_);
74 Node* myleft =
static_cast<Node*
>(left_);
75 assert(myleft->parent_ == me);
76 assert(myroot->compare(*me, *left_) <= 0);
77 assert(myroot->compare(*left_, *me) >= 0);
81 Node* myright =
static_cast<Node*
>(right_);
82 assert(myright->parent_ == me);
83 assert(myroot->compare(*me, *right_) >= 0);
84 assert(myroot->compare(*right_, *me) <= 0);
94 R
const* me =
static_cast<R const*
>(
this);
96 Node* node =
static_cast<Node*
>(base_);
98 assert(node->parent_ == 0);
114 while (mynode->left_) {
115 node = mynode->left_;
118 return const_cast<N*
>(node);
122 node =
static_cast<N const*
>(mynode);
123 while (mynode->parent_) {
124 N*
parent = mynode->parent_;
126 if (mynode->left_ == node) {
144 while (mynode->right_) {
145 node = mynode->right_;
148 return const_cast<N*
>(node);
152 node =
static_cast<N const*
>(mynode);
153 while (mynode->parent_) {
154 N*
parent = mynode->parent_;
156 if (mynode->right_ == node) {
165 if (base_ == 0)
return 0;
168 while (mynode->left_) {
169 node = mynode->left_;
177 if (base_ == 0)
return 0;
180 while (mynode->right_) {
181 node = mynode->right_;
193 static_cast<Root*
>(root_)->
check();
194 Node*
parent =
static_cast<Node*
>(parent_);
210 Node* nl =
static_cast<Node*
>(newLink);
214 static_cast<Node*
>(right_)->parent_ = newLink;
216 if (newLink != left_){
220 static_cast<Node*
>(nl->parent_)->right_ = nl->left_;
222 static_cast<Node*
>(nl->left_)->parent_ = nl->parent_;
227 static_cast<Node*
>(left_)->parent_ = newLink;
234 static_cast<Node*
>(newLink)->parent_ = parent_;
238 if (parent->left_ == static_cast<N*>(
this)) {
239 parent->left_ = newLink;
241 parent->right_ = newLink;
244 static_cast<Root*
>(root_)->base_ = newLink;
246 static_cast<Root*
>(root_)->
check();
262 Node& mynode =
static_cast<Node&
>(node);
263 if (mynode.root_ ==
this) {
278 if (node != 0)
remove(*node);
291 if (mynode.root_ ==
this)
return;
292 if (mynode.root_ != 0) mynode.remove();
296 Node* mynodebase = nodebase;
297 int cmp = compare(*nodebase, node);
299 if (mynodebase->left_) {
300 nodebase = mynodebase->left_;
302 mynodebase->left_ = &node;
303 mynode.parent_ = nodebase;
307 if (mynodebase->right_) {
308 nodebase = mynodebase->right_;
310 mynodebase->right_ = &node;
311 mynode.parent_ = nodebase;
322 mynode.root_ =
static_cast<R*
>(
this);
337 if (node != 0) add(*node);
349 static_cast<Root&
>(
root).add(*static_cast<N*>(
this));
374 int cmp = compareKey(*node, key);
377 node =
static_cast<Node*
>(node)->left_;
379 node =
static_cast<Node*
>(node)->right_;
407 }
else if (node->right_) {
410 Node*
parent = node->parent_;
415 if (parent->left_ == node) {
418 if (parent->right_ == node) {
TreeInRoot()
Definition: TreeIn.hpp:390
N * last() const
Definition: TreeIn.hpp:176
void check() const
Definition: TreeIn.hpp:93
void check() const
Definition: TreeIn.hpp:61
N * parent() const
Definition: TreeIn.h:179
void remove(N &node)
Definition: TreeIn.hpp:261
virtual void remove()
Definition: TreeIn.hpp:191
~TreeInNode()
Definition: TreeIn.hpp:444
N * first() const
Definition: TreeIn.hpp:164
virtual void add(N &node)
Definition: TreeIn.hpp:289
N * next() const
Definition: TreeIn.hpp:107
void addTo(R &root)
Definition: TreeIn.hpp:348
Intrusive Binary Tree (unbalenced).
#define assert
Definition: TreeIn.hpp:45
N * prev() const
Definition: TreeIn.hpp:137
~TreeInRoot()
Definition: TreeIn.hpp:402
N * find(K key) const
Definition: TreeIn.hpp:371
TreeInNode()
Definition: TreeIn.hpp:432
R * root() const
Return pointer to list we are on.
Definition: TreeIn.h:178