-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbTree.h
More file actions
1252 lines (1252 loc) · 27.5 KB
/
bTree.h
File metadata and controls
1252 lines (1252 loc) · 27.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
////
//// Created by Ignacio Mora on 6/15/17.
////
//
//#ifndef MASTERENGINE_BTREE_H
//#define MASTERENGINE_BTREE_H
//
//
///*
//
//current version: may 9th, 2003
//
//
//
//this file contains a class template for elements stored in a B-tree, and a
//
//class for a B-tree node, which provides all the methods needed to search,
//
//insert, or delete. a sample "main" function is also provided to show
//
//how to use the B-tree.
//
//to understand the identifiers and comments, visualize the tree as having
//
//its root node at the top of the diagram, its leaf nodes at the bottom of
//
//the diagram, and each node as containing an array oriented horizontally,
//
//with the smallest element on the left and the largest element on the right.
//
//the zeroth element of a node contains only a subtree pointer, no key value
//
//or payload.
//
//
//
//a b-tree grows "upward", by splitting the root node when the node's capacity
//
//is exceeded. conversely, the depth of the tree is always reduced by merging
//
//the last remaining element of the root node with the elements of its two
//
//child nodes, so the tree contracts "from the top".
//
//
//
//this code may be freely copied.
//
//programmer: toucan@textelectric.net
//
//algorithm and pseudo-code found in:
//
//"fundamentals of data structures in pascal", by Horowitz and Sahni
//
//
//
//there is a java applet on the web that draws a b-tree diagram and allows the
//
//user to perform insertions and deletions, so you can see how it grows and shrinks,
//
//at: http://www.mars.dti.ne.jp/~torao/program/structure/btree.html
//
//*/
//
//
//
//#include <iostream>
//
//#include <string>
//
//#include <vector>
//
//#include <strstream>
//
//using namespace std;
//
//
//class Node;
//
//Node* invalid_ptr = reinterpret_cast<Node*> (-1);
//
//Node* null_ptr = reinterpret_cast<Node*> (0);
//
//const int invalid_index = -1;
//
//const int max_elements = 20; // max elements in a node
//
//// size limit for the array in a vector object. best performance was
//
//// at 800 bytes.
//
//const int max_array_bytes = 800;
//
//
//template<class key, class payload> class Element {
//
//// contains a key value, a payload, and a pointer toward the subtree
//
//// containing key values greater than this->m_key but lower than the
//
//// key value of the next element to the right
//
//
//
//public:
//
// key m_key;
//
// payload m_payload;
//
// Node* mp_subtree;
//
//public:
//
// bool operator> (Element& other) const { return m_key > other.m_key; }
//
// bool operator< (Element& other) const { return m_key < other.m_key; }
//
// bool operator>= (Element& other) const { return m_key >= other.m_key; }
//
// bool operator<= (Element& other) const { return m_key <= other.m_key; }
//
// bool operator== (Element& other) const { return m_key == other.m_key; }
//
// bool valid () const { return mp_subtree != invalid_ptr; }
//
// void invalidate () { mp_subtree = invalid_ptr; }
//
// Element& operator= (const Element& other) {
//
// m_key = other.m_key;
//
// m_payload = other.m_payload;
//
// mp_subtree = other.mp_subtree;
//
// return *this;
//
// }
//
// Element () { mp_subtree = null_ptr; }
//
// void dump ();
//
//}; //______________________________________________________________________
//
//
//
//template<class key, class payload> void Element<key, payload>::dump () {
//
// cout << "key=" << m_key << "sub=" << mp_subtree << ' ';
//
//} //_______________________________________________________________________
//
//
//
//typedef Element<string, string> Elem;
//
//
//class RootTracker;
//
//
//class Node {
//
//protected:
//
// // locality of reference, beneficial to effective cache utilization,
//
// // is provided by a "vector" container rather than a "list"
//
// vector<Elem> m_vector;
//
// // number of elements currently in m_vector, including the zeroth element
//
// // which has only a subtree, no key value or payload.
//
// int m_count;
//
// Node* mp_parent;
//
// bool is_leaf();
//
// bool vector_insert (Elem& element);
//
// bool vector_insert_for_split (Elem& element);
//
// bool split_insert (Elem& element);
//
// bool vector_delete (Elem& target);
//
// bool vector_delete (int target_pos);
//
// void insert_zeroth_subtree (Node* subtree);
//
// void set_debug();
//
// int key_count () { return m_count-1; }
//
// Elem& largest_key () { return m_vector[m_count-1]; }
//
// Elem& smallest_key () { return m_vector[1]; }
//
// Elem& smallest_key_in_subtree();
//
// int index_has_subtree ();
//
// Node* right_sibling (int& parent_index_this);
//
// Node* left_sibling (int& parent_index_this);
//
// Node* rotate_from_left(int parent_index_this);
//
// Node* rotate_from_right(int parent_index_this);
//
// Node* merge_right (int parent_index_this);
//
// Node* merge_left (int parent_index_this);
//
// bool merge_into_root ();
//
// int minimum_keys ();
//
//#ifdef _DEBUG
//
// Elem debug[8];
//
//#endif
//
//public:
//
// Elem& search (Elem& desired, Node*& last_visited);
//
// bool tree_insert (Elem& element);
//
// bool delete_element (Elem& target);
//
// int delete_all_subtrees ();
//
// Node* find_root();
//
// // to return a reference when a search fails.
//
// static Elem m_failure;
//
// // the root of the tree may change. this attribute keeps it accessible.
//
// RootTracker& m_root;
//
// Elem& operator[] (int i) { return m_vector[i]; }
//
// // node cannot be instantiated without a root tracker
//
// Node (RootTracker& root_track);
//
// void dump ();
//
//
//
//}; //______________________________________________________________________
//
//
//
//class RootTracker {
//
//// all the node instances that belong to a given tree have a reference to one
//
//// instance of RootTracker. as the Node instance that is the root may change
//
//// or the original root may be deleted, Node instances must access the root
//
//// of the tree through this tracker, and update the root pointer when they
//
//// perform insertions or deletions. using a static attribute in the Node
//
//// class to hold the root pointer would limit a program to just one B-tree.
//
//protected:
//
// Node* mp_root;
//
//public:
//
// RootTracker() { mp_root = null_ptr; }
//
// void set_root (Node* old_root, Node* new_root) {
//
// // ensure that the root is only being changed by a node belonging to the
//
// // same tree as the current root
//
// if (old_root != mp_root)
//
// throw "wrong old_root in RootTracker::set_root";
//
// else
//
// mp_root = new_root;
//
// }
//
// Node* get_root () { return mp_root; }
//
//
// ~RootTracker () {
//
// // safety measure
//
// if (mp_root) {
//
// mp_root->delete_all_subtrees();
//
// delete mp_root;
//
// }
//
// }
//
//}; //_______________________________________________________________________
//
//
//
//int Node::minimum_keys () {
//
// // minus 1 for the empty slot left for splitting the node
//
// int size = m_vector.size();
//
// int ceiling_func = (size-1)/2;
//
// if (ceiling_func*2 < size-1)
//
// ceiling_func++;
//
// return ceiling_func-1; // for clarity, may increment then decrement
//
//} //________________________________________________________________________
//
//
//
//inline void Node::set_debug() {
//
//#ifdef _DEBUG
//
// // the contents of an STL vector are not visible in the visual C++ debugger,
//
//// so this function copies up to eight elements from the STL vector into
//
//// a simple C++ array.
//
// for (int i=0; i<m_count && i<8; i++) {
//
// debug[i] = m_vector[i];
//
// if (m_vector[i].mp_subtree)
//
// m_vector[i].mp_subtree->set_debug();
//
// }
//
// for ( ; i<8; i++)
//
// debug[i] = m_failure;
//
//#endif
//
//} //________________________________________________________________________
//
//
//
//void Node::insert_zeroth_subtree (Node* subtree) {
//
// m_vector[0].mp_subtree = subtree;
//
// m_vector[0].m_key = "";
//
// m_count = 1;
//
// if (subtree)
//
// subtree->mp_parent = this;
//
//} //_________________________________________________________________________
//
//
//
//void Node::dump (){
//
//// write out the keys in this node and all its subtrees, along with
//
//// node adresses, for debugging purposes
//
// if (this == m_root.get_root())
//
// cout << "ROOT\n";
//
// cout << "\nthis=" << this << endl;
//
// cout << "parent=" << mp_parent << " count=" << m_count << endl;
//
// for (int i=0; i<m_count; i++) {
//
// m_vector[i].dump();
// }
//
// for (int i=0; i<m_count; i++) {
//
// if (m_vector[i].mp_subtree) {
//
// m_vector[i].mp_subtree->dump();
// }
// }
// cout << endl;
//
//} //________________________________________________________________________
//
//
//
//Node::Node (RootTracker& root_track) : m_root(root_track) {
//
//// limit the size of the vector to 4 kilobytes max and 200 entries max.
//
// int num_elements = max_elements*sizeof(Elem)<=max_array_bytes ?
//
// max_elements : max_array_bytes/sizeof(Elem);
//
// if (num_elements < 6) // in case key or payload is really huge
//
// num_elements = 6;
//
// m_vector.resize (num_elements);
//
// m_count = 0;
//
// mp_parent = 0;
//
// insert_zeroth_subtree (0);
//
//} //________________________________________________________________________
//
//
//
//Node* Node::find_root () {
//
// Node* current = this;
//
// while (current->mp_parent)
//
// current = current->mp_parent;
//
// return current;
//
//} //__________________________________________________________________________
//
//
//
//bool Node::is_leaf () {
//
// return m_vector[0].mp_subtree==0;
//
//} //________________________________________________________________________
//
//
//
//int Node::delete_all_subtrees () {
//
//// return the number of nodes deleted
//
// int count_deleted = 0;
//
// for (int i=0; i< m_count; i++) {
//
// if (!m_vector[i].mp_subtree)
//
// continue;
//
// else if (m_vector[i].mp_subtree->is_leaf()) {
//
// delete m_vector[i].mp_subtree;
//
// count_deleted++;
//
// }
//
// else
//
// count_deleted += m_vector[i].mp_subtree->delete_all_subtrees();
//
// }
//
// return count_deleted;
//
//} //_______________________________________________________________________
//
//
//
//bool Node::vector_insert (Elem& element) {
//
//// this method merely tries to insert the argument into the current node.
//
//// it does not concern itself with the entire tree.
//
//// if the element can fit into m_vector, slide all the elements
//
//// greater than the argument forward one position and copy the argument
//
//// into the newly vacated slot, then return true. otherwise return false.
//
//// note: the tree_insert method will already have verified that the key
//
//// value of the argument element is not present in the tree.
//
//
//
// if (m_count >= m_vector.size()-1) // leave an extra slot for split_insert
//
// return false;
//
// int i = m_count;
//
//
//
// while (i>0 && m_vector[i-1]>element) {
//
// m_vector[i] = m_vector[i-1];
//
// i--;
//
// }
//
// if (element.mp_subtree)
//
// element.mp_subtree->mp_parent = this;
//
// m_vector[i] = element;
//
// m_count++;
//
// return true;
//
//} //__________________________________________________________________
//
//
//
//bool Node::vector_delete (Elem& target) {
//
//// delete a single element in the vector belonging to *this node.
//
//// if the target is not found, do not look in subtrees, just return false.
//
//
//
// int target_pos = -1;
//
// int first = 1;
//
// int last = m_count-1;
//
// // perform binary search
//
// while (last-first > 1) {
//
// int mid = first+(last-first)/2;
//
// if (target>=m_vector[mid])
//
// first = mid;
//
// else
//
// last = mid;
//
// }
//
// if (m_vector[first]==target)
//
// target_pos = first;
//
// else if (m_vector[last]==target)
//
// target_pos = last;
//
// else
//
// return false;
//
// // the element's subtree, if it exists, is to be deleted or re-attached
//
// // in a different function. not a concern here. just shift all the
//
// // elements in positions greater than target_pos.
//
// for (int i=target_pos; i<m_count; i++)
//
// m_vector[i] = m_vector[i+1];
//
//
//
// m_count--;
//
// return true;
//
//} //____________________________________________________________________
//
//
//
//bool Node::vector_delete (int target_pos) {
//
//// delete a single element in the vector belonging to *this node.
//
//// the element is identified by position, not value.
//
//
//
// if (target_pos<0 || target_pos>=m_count)
//
// return false;
//
//
//
// // the element's subtree, if it exists, is to be deleted or re-attached
//
// // in a different function. not a concern here. just shift all the
//
// // elements in positions greater than target_pos.
//
// for (int i=target_pos; i<m_count; i++)
//
// m_vector[i] = m_vector[i+1];
//
//
//
// m_count--;
//
// return true;
//
//} //____________________________________________________________________
//
//
//
//bool Node::vector_insert_for_split (Elem& element) {
//
//// this method insert an element that is in excess of the nominal capacity of
//
//// the node, using the extra slot that always remains unused during normal
//
//// insertions. this method should only be called from split_insert()
//
//
//
// if (m_count >= m_vector.size()) // error
//
// return false;
//
// int i = m_count;
//
//
//
// while (i>0 && m_vector[i-1]>element) {
//
// m_vector[i] = m_vector[i-1];
//
// i--;
//
// }
//
// if (element.mp_subtree)
//
// element.mp_subtree->mp_parent = this;
//
// m_vector[i] = element;
//
// m_count++;
//
// return true;
//
//} //__________________________________________________________________
//
//
//
//bool Node::split_insert (Elem& element) {
//
//
// // split_insert should only be called if node is full
//
// if (m_count != m_vector.size()-1)
//
// throw "bad m_count in split_insert";
//
//
// vector_insert_for_split (element);
//
// int split_point = m_count/2;
//
// if (2*split_point < m_count) // perform the "ceiling function"
//
// split_point++;
//
// // new node receives the rightmost half of elements in *this node
//
// Node* new_node = new Node(m_root);
//
// Elem upward_element = m_vector[split_point];
//
// new_node->insert_zeroth_subtree (upward_element.mp_subtree);
//
// upward_element.mp_subtree = new_node;
//
// // element that gets added to the parent of this node
//
// for (int i=1; i<m_count-split_point; i++)
//
// new_node->vector_insert(m_vector[split_point+i]);
//
// new_node->m_count = m_count-split_point;
//
// m_count = split_point;
//
// new_node->mp_parent = mp_parent;
//
//
// // now insert the new node into the parent, splitting it if necessary
//
// if (mp_parent && mp_parent->vector_insert(upward_element))
//
// return true;
//
// else if (mp_parent && mp_parent->split_insert(upward_element))
//
// return true;
//
// else if (!mp_parent) { // this node was the root
//
// Node* new_root = new Node(m_root);
//
// new_root->insert_zeroth_subtree(this);
//
// this->mp_parent = new_root;
//
// new_node->mp_parent = new_root;
//
// new_root->vector_insert (upward_element);
//
// m_root.set_root (m_root.get_root(), new_root);
//
// new_root->mp_parent = 0;
//
// }
//
// return true;
//
//
//
//}//__________________________________________________________________
//
//
//
//bool Node::tree_insert (Elem& element) {
//
// Node* last_visited_ptr = this;
//
// if (search(element, last_visited_ptr).valid()) // element already in tree
//
// return false;
//
// if (last_visited_ptr->vector_insert(element))
//
// return true;
//
// return last_visited_ptr->split_insert(element);
//
//} //__________________________________________________________________
//
//
//
//bool Node::delete_element (Elem& target) {
//
//// target is just a package for the key value. the reference does not
//
//// provide the address of the Elem instance to be deleted.
//
//
//
//
//
// // first find the node contain the Elem instance with the given key
//
// Node* node = 0;
//
// int parent_index_this = invalid_index;
//
// Elem& found = search (target, node);
//
// if (!found.valid())
//
// return false;
//
//
// if (node->is_leaf() && node->key_count() > node->minimum_keys())
//
// return node->vector_delete (target);
//
// else if (node->is_leaf()) {
//
// node->vector_delete (target);
//
// // loop invariant: if _node_ is not null_ptr, it points to a node
//
// // that has lost an element and needs to import one from a sibling
//
// // or merge with a sibling and import one from its parent.
//
// // after an iteration of the loop, _node_ may become null or
//
// // it may point to its parent if an element was imported from the
//
// // parent and this caused the parent to fall below the minimum
//
// // element count.
//
// while (node) {
//
// // NOTE: the "this" pointer may no longer be valid after the first
//
// // iteration of this loop!!!
//
// if (node==node->find_root() && node->is_leaf())
//
// break;
//
// if (node==node->find_root() && !node->is_leaf()) // sanity check
//
// throw "node should not be root in delete_element loop";
//
// // is an extra element available from the right sibling (if any)
//
// Node* right = node->right_sibling(parent_index_this);
//
// if (right && right->key_count() > right->minimum_keys())
//
// node = node->rotate_from_right(parent_index_this);
//
// else {
//
// // is an extra element available from the left sibling (if any)
//
// Node* left = node->left_sibling(parent_index_this);
//
// if (left && left->key_count() > left->minimum_keys())
//
// node = node->rotate_from_left(parent_index_this);
//
// else if (right)
//
// node = node->merge_right(parent_index_this);
//
// else if (left)
//
// node = node->merge_left(parent_index_this);
//
// }
//
// }
//
// }
//
// else {
//
// Elem& smallest_in_subtree = found.mp_subtree->smallest_key_in_subtree();
//
// found.m_key = smallest_in_subtree.m_key;
//
// found.m_payload = smallest_in_subtree.m_payload;
//
// found.mp_subtree->delete_element (smallest_in_subtree);
//
// }
//
// return true;
//
//} //___________________________________________________________________
//
//
//
//Node* Node::rotate_from_right(int parent_index_this) {
//
// // new element to be added to this node
//
// Elem underflow_filler = (*mp_parent)[parent_index_this+1];
//
// // right sibling of this node
//
// Node* right_sib = (*mp_parent)[parent_index_this+1].mp_subtree;
//
// underflow_filler.mp_subtree = (*right_sib)[0].mp_subtree;
//
// // copy the entire element
//
// (*mp_parent)[parent_index_this+1] = (*right_sib)[1];
//
// // now restore correct pointer
//
// (*mp_parent)[parent_index_this+1].mp_subtree = right_sib;
//
// vector_insert (underflow_filler);
//
// right_sib->vector_delete(0);
//
// (*right_sib)[0].m_key = "";
//
// (*right_sib)[0].m_payload = "";
//
// return null_ptr; // parent node still has same element count
//
//} //_______________________________________________________________________
//
//
//
//Node* Node::rotate_from_left(int parent_index_this) {
//
// // new element to be added to this node
//
// Elem underflow_filler = (*mp_parent)[parent_index_this];
//
// // left sibling of this node
//
// Node* left_sib = (*mp_parent)[parent_index_this-1].mp_subtree;
//
// underflow_filler.mp_subtree = (*this)[0].mp_subtree;
//
// (*this)[0].mp_subtree = (*left_sib)[left_sib->m_count-1].mp_subtree;
//
// if ((*this)[0].mp_subtree)
//
// (*this)[0].mp_subtree->mp_parent = this;
//
// // copy the entire element
//
// (*mp_parent)[parent_index_this] = (*left_sib)[left_sib->m_count-1];
//
// // now restore correct pointer
//
// (*mp_parent)[parent_index_this].mp_subtree = this;
//
// vector_insert (underflow_filler);
//
// left_sib->vector_delete(left_sib->m_count-1);
//
// return null_ptr; // parent node still has same element count
//
//} //_______________________________________________________________________
//
//
//
//Node* Node::merge_right (int parent_index_this) {
//
//// copy elements from the right sibling into this node, along with the
//
//// element in the parent node vector that has the right sibling as it subtree.
//
//// the right sibling and that parent element are then deleted
//
//
//
// Elem parent_elem = (*mp_parent)[parent_index_this+1];
//
// Node* right_sib = (*mp_parent)[parent_index_this+1].mp_subtree;
//
// parent_elem.mp_subtree = (*right_sib)[0].mp_subtree;
//
// vector_insert (parent_elem);
//
// for (int i=1; i<right_sib->m_count; i++)
//
// vector_insert ((*right_sib)[i]);
//
// mp_parent->vector_delete (parent_index_this+1);
//
// delete right_sib;
//
// if (mp_parent==find_root() && !mp_parent->key_count()) {
//
// m_root.set_root(m_root.get_root(), this);
//
// delete mp_parent;
//
// mp_parent = 0;
//
// return null_ptr;
//
// }
//
// else if (mp_parent==find_root() && mp_parent->key_count())
//
// return null_ptr;
//
// if (mp_parent&& mp_parent->key_count() >= mp_parent->minimum_keys())
//
// return null_ptr; // no need for parent to import an element
//
// return mp_parent; // parent must import an element