6 template <
class Key,
class Data>
class AVLTree;
8 template <
class Key,
class Data>
36 bool resturctureInsert();
37 bool resturctureDelete();
41 template <
class Key,
class Data>
49 template <
class Key,
class Data>
58 template <
class Key,
class Data>
63 return right->getFirstInOrder();
65 if(isLeftChild())
return parent;
81 template <
class Key,
class Data>
86 return left->getLastInOrder();
88 if(isRightChild())
return parent;
104 template <
class Key,
class Data>
107 if(left)left->getTree(list);
109 if(right)right->getTree(list);
112 template <
class Key,
class Data>
116 if(left)left->print();
117 if(right)right->print();
119 template <
class Key,
class Data>
122 unsigned int l = 0, r = 0;
123 if(left)l = left->depth();
124 if(right)r = right->depth();
125 return (l>r?l:r) + 1;
128 template <
class Key,
class Data>
133 this->balance = balance;
134 this->parent = parent;
139 template <
class Key,
class Data>
143 if(right)
delete right;
146 template <
class Key,
class Data>
154 template <
class Key,
class Data>
159 return parent->left ==
this;
164 template <
class Key,
class Data>
169 return parent->right ==
this;
174 template <
class Key,
class Data>
182 if(!cur->
left)
return cur;
189 if(!cur->
right)
return cur;
201 template <
class Key,
class Data>
204 if(!right)
return false;
221 if(right != NULL)right->
parent =
this;
235 template <
class Key,
class Data>
238 if(left == NULL)
return false;
255 if(left != NULL)left->
parent =
this;
269 template <
class Key,
class Data>
272 if(left == NULL || left->right == NULL)
return false;
290 if (left != NULL) left->
parent =
this;
310 template <
class Key,
class Data>
313 if(right == NULL || right->left == NULL)
return false;
330 if (right != NULL) right->
parent =
this;
351 template <
class Key,
class Data>
399 template <
class Key,
class Data>
512 template <
class Key,
class Data>
518 void add(Key key, Data);
528 unsigned long nodeCount;
531 template <
class Key,
class Data>
539 template <
class Key,
class Data>
546 template <
class Key,
class Data>
552 template <
class Key,
class Data>
555 if(__builtin_expect(root!=NULL, 1))
558 if(__builtin_expect(item != NULL, 1))
561 if(__builtin_expect(newItem != NULL, 1))
565 item->
left = newItem;
569 item->
right = newItem;
571 newItem->resturctureInsert();
572 root = root->getRoot();
585 template <
class Key,
class Data>
591 if(cur->
key == key)
return cur;
597 template <
class Key,
class Data>
600 if(!root)
return false;
602 if(item == NULL)
return false;
605 if(item->
left == NULL && item->
right == NULL)
614 if(item->
left == NULL && item->
right == NULL)
624 if(item != NULL && item->
left == NULL && item->
right != NULL)
632 if(item != NULL && item->
left != NULL && item->
right == NULL)
640 if(item != NULL && item->
left != NULL && item->
right != NULL)
665 startitem->resturctureDelete();
666 while(root->parent)root = root->parent;