43 #include "bj_stream.h" 44 #include "stack_trace.h" 46 #define DBG_RBT(prm) DBG(prm) 47 #define REDBLACK_CK(prm) DBG_CK(prm) 51 #define SLOW_REDBLACK_CK(prm) 73 typedef char comparison;
84 template <
bool>
struct RBT_ILLEGAL_USE_OF_OBJECT;
85 template <>
struct RBT_ILLEGAL_USE_OF_OBJECT<true>{};
86 #define RBT_OBJECT_COPY_ERROR RBT_ILLEGAL_USE_OF_OBJECT<false>() 88 template<
class node_manager_t>
91 typedef typename node_manager_t::rbt_nod_ref_t rbt_nod_ref_t;
92 typedef typename node_manager_t::rbt_obj_t rbt_obj_t;
96 node_manager_t& the_mgr;
99 rbt_nod_ref_t last_found;
100 rbt_nod_ref_t min_nod;
101 rbt_nod_ref_t max_nod;
105 redblack(node_manager_t& mgr) : the_mgr(mgr){
116 redblack& operator = (redblack& other) {
117 RBT_OBJECT_COPY_ERROR;
120 redblack(redblack& other){
121 RBT_OBJECT_COPY_ERROR;
124 void clear_redblack(){
133 rbt_nod_ref_t get_min(){
137 rbt_nod_ref_t get_max(){
141 rbt_nod_ref_t search(rbt_obj_t
const & obj){
142 rbt_nod_ref_t the_parent;
143 return search_node(obj, the_parent);
146 rbt_nod_ref_t rbt_insert(rbt_obj_t
const & obj);
147 rbt_nod_ref_t predecessor(rbt_nod_ref_t xx);
148 rbt_nod_ref_t successor(rbt_nod_ref_t xx);
149 rbt_nod_ref_t rbt_remove(rbt_nod_ref_t zz);
151 bool ee = (root == get_null());
152 REDBLACK_CK(! ee || (rbt_sz == 0));
163 bj_ostream& print(bj_ostream& os,
164 bool just_chks =
false,
bool htm =
false);
167 bj_ostream& operator << (bj_ostream& os, redblack<node_manager_t>& rbt){
181 rbt_nod_ref_t get_null(){
182 return the_mgr.get_null_node_reference();
185 rbt_obj_t& get_obj(rbt_nod_ref_t
const & nd){
186 return the_mgr.get_object_of(nd);
189 bool is_alone(rbt_nod_ref_t
const & nd);
190 bool check_refs(rbt_nod_ref_t
const & nd,
int from = 0);
191 void move_node(rbt_nod_ref_t
const & nd, rbt_nod_ref_t
const & nd_empty);
195 rbt_nod_ref_t create_node(rbt_obj_t
const & obj1){
196 return the_mgr.create_node(obj1);
199 void destroy_nodes(){
200 the_mgr.destroy_all_nodes(*
this);
203 comparison cmp(rbt_nod_ref_t nod1, rbt_nod_ref_t nod2){
204 return the_mgr.compare_node_objects(get_obj(nod1), get_obj(nod2));
207 comparison cmp_obj(rbt_nod_ref_t nod1, rbt_obj_t
const & obj){
208 return the_mgr.compare_node_objects(get_obj(nod1), obj);
211 comparison cmp_objs(rbt_obj_t
const & obj1, rbt_obj_t
const & obj2){
212 return the_mgr.compare_node_objects(obj1, obj2);
215 rbt_nod_ref_t& get_right(rbt_nod_ref_t
const & nd){
216 return the_mgr.get_right_node_reference_of(nd);
219 rbt_nod_ref_t& get_left(rbt_nod_ref_t
const & nd){
220 return the_mgr.get_left_node_reference_of(nd);
223 rbt_nod_ref_t& get_parent(rbt_nod_ref_t
const & nd){
224 return the_mgr.get_parent_node_reference_of(nd);
227 rbt_color_t get_color(rbt_nod_ref_t
const & nd){
228 return the_mgr.get_color_of(nd);
231 void set_color(rbt_nod_ref_t
const & nd, rbt_color_t col){
232 the_mgr.set_color_of(nd, col);
235 rbt_nod_ref_t& get_grand(rbt_nod_ref_t
const & nd){
236 return get_parent(get_parent(nd));
239 void init_red_black(){
241 last_found = get_null();
242 min_nod = get_null();
243 max_nod = get_null();
247 bool check_min_max(){
248 rbt_nod_ref_t min_found = search_min(root);
249 rbt_nod_ref_t max_found = search_max(root);
250 REDBLACK_CK(min_nod == min_found);
251 REDBLACK_CK(max_nod == max_found);
252 REDBLACK_CK(check_refs(root, 1));
253 REDBLACK_CK(check_refs(last_found, 2));
254 REDBLACK_CK(check_refs(min_nod, 3));
255 REDBLACK_CK(check_refs(max_nod, 4));
259 void insert_update_min_max(rbt_nod_ref_t nod){
261 REDBLACK_CK(nod != get_null());
262 if((min_nod == get_null()) || (cmp(min_nod, nod) > 0)){
265 if((max_nod == get_null()) || (cmp(max_nod, nod) < 0)){
270 void remove_update_min_max(rbt_nod_ref_t nod){
272 REDBLACK_CK(nod != get_null());
273 REDBLACK_CK(min_nod != get_null());
274 REDBLACK_CK(max_nod != get_null());
275 if(cmp(min_nod, nod) == 0){
276 REDBLACK_CK(get_left(min_nod) == get_null());
277 REDBLACK_CK(min_nod == nod);
278 min_nod = successor(nod);
280 if(cmp(max_nod, nod) == 0){
281 REDBLACK_CK(get_right(max_nod) == get_null());
282 REDBLACK_CK(max_nod == nod);
283 max_nod = predecessor(nod);
287 void move_update_min_max(rbt_nod_ref_t src,
290 if(last_found == src){
304 rbt_nod_ref_t search_node(rbt_obj_t
const & obj, rbt_nod_ref_t& the_parent);
306 rbt_nod_ref_t search_min(rbt_nod_ref_t xx);
307 rbt_nod_ref_t search_max(rbt_nod_ref_t xx);
308 void left_rotate(rbt_nod_ref_t xx);
309 void right_rotate(rbt_nod_ref_t yy);
310 void fix_remove(rbt_nod_ref_t xx, rbt_nod_ref_t parent_yy);
312 bool is_black(rbt_nod_ref_t nod){
313 if(nod == get_null()){
return true; }
314 return (get_color(nod) == k_black_color);
317 bool is_red(rbt_nod_ref_t nod){
318 if(nod == get_null()){
return false; }
319 return (get_color(nod) == k_red_color);
322 void set_black(rbt_nod_ref_t nod){
323 if(nod == get_null()){
return; }
324 set_color(nod, k_black_color);
327 void set_red(rbt_nod_ref_t nod){
328 if(nod == get_null()){
return; }
329 set_color(nod, k_red_color);
332 bj_ostream& print_rec(bj_ostream& os, rbt_nod_ref_t xx,
int tb,
333 bool& prev, rbt_nod_ref_t nod,
int& tot,
334 int ctr,
bool just_cks);
341 template<
class node_manager_t>
342 class redblack_iter {
344 typedef typename node_manager_t::rbt_nod_ref_t rbt_nod_ref_t;
345 typedef typename node_manager_t::rbt_obj_t rbt_obj_t;
347 redblack<node_manager_t>& the_tree;
348 rbt_nod_ref_t the_ref;
350 redblack_iter(redblack<node_manager_t>& rbt) : the_tree(rbt){
351 the_ref = the_tree.get_null();
353 redblack_iter(redblack_iter& rbt_it): the_tree(rbt_it.the_tree){
354 the_ref = the_tree.get_null();
360 return the_tree.size();
364 REDBLACK_CK(the_tree.check_refs(the_ref, 5));
365 the_ref = the_tree.get_min();
369 REDBLACK_CK(the_tree.check_refs(the_ref, 6));
370 the_ref = the_tree.get_max();
373 rbt_obj_t& get_obj(){
374 REDBLACK_CK(the_tree.check_refs(the_ref, 7));
375 return the_tree.get_obj(the_ref);
379 REDBLACK_CK(the_tree.check_refs(the_ref, 8));
380 return (the_ref == the_tree.get_null());
384 REDBLACK_CK(the_tree.check_refs(the_ref, 9));
385 the_ref = the_tree.successor(the_ref);
389 REDBLACK_CK(the_tree.check_refs(the_ref, 10));
390 the_ref = the_tree.predecessor(the_ref);
393 rbt_nod_ref_t get_ref(){
394 REDBLACK_CK(the_tree.check_refs(the_ref, 11));
406 void operator ++ (
int) { ++(*this); }
408 void operator -- (
int) { --(*this); }
414 template<
class node_manager_t>
416 redblack<node_manager_t>::is_alone(rbt_nod_ref_t
const & nd){
418 (nd != get_null()) &&
419 (get_parent(nd) == get_null()) &&
420 (get_right(nd) == get_null()) &&
421 (get_left(nd) == get_null())
426 template<
class node_manager_t>
428 redblack<node_manager_t>::check_refs(rbt_nod_ref_t
const & nd,
int from){
429 if(nd == get_null()){
433 rbt_nod_ref_t pre = get_parent(nd);
434 rbt_nod_ref_t lft = get_left(nd);
435 rbt_nod_ref_t rgt = get_right(nd);
437 if(pre != get_null()){
438 rbt_nod_ref_t pre_lft = get_left(pre);
439 rbt_nod_ref_t pre_rgt = get_right(pre);
440 REDBLACK_CK((pre_lft == nd) || (pre_rgt == nd));
442 if(lft != get_null()){
443 rbt_nod_ref_t lft_pre = get_parent(lft);
444 REDBLACK_CK(lft_pre == nd);
446 if(rgt != get_null()){
447 rbt_nod_ref_t rgt_pre = get_parent(rgt);
448 REDBLACK_CK(rgt_pre == nd);
453 template<
class node_manager_t>
455 redblack<node_manager_t>::move_node(rbt_nod_ref_t
const & nd, rbt_nod_ref_t
const & alone){
456 REDBLACK_CK(is_alone(alone));
457 REDBLACK_CK(alone != nd);
458 REDBLACK_CK(check_refs(nd, 12));
459 REDBLACK_CK(check_refs(alone, 13));
461 rbt_nod_ref_t pre = get_parent(nd);
462 if(pre != get_null()){
463 if(get_right(pre) == nd){
464 get_right(pre) = alone;
465 }
else if(get_left(pre) == nd){
466 get_left(pre) = alone;
469 rbt_nod_ref_t lft_nod = get_left(nd);
470 if(lft_nod != get_null()){
471 get_parent(lft_nod) = alone;
473 rbt_nod_ref_t rgt_nod = get_right(nd);
474 if(rgt_nod != get_null()){
475 get_parent(rgt_nod) = alone;
478 get_obj(alone) = get_obj(nd);
479 get_parent(alone) = get_parent(nd);
480 get_left(alone) = get_left(nd);
481 get_right(alone) = get_right(nd);
482 set_color(alone, get_color(nd));
484 get_parent(nd) = get_null();;
485 get_left(nd) = get_null();;
486 get_right(nd) = get_null();;
487 REDBLACK_CK(is_alone(nd));
489 move_update_min_max(nd, alone);
491 REDBLACK_CK(check_refs(nd, 14));
492 REDBLACK_CK(check_refs(alone, 15));
493 SLOW_REDBLACK_CK(check_min_max());
497 template<
class node_manager_t>
498 typename redblack<node_manager_t>::rbt_nod_ref_t
499 redblack<node_manager_t>::search_node(rbt_obj_t
const & obj, rbt_nod_ref_t& the_parent)
501 if((last_found != get_null()) && (cmp_obj(last_found, obj) == 0)){
502 the_parent = get_parent(last_found);
505 the_parent = get_null();
506 rbt_nod_ref_t child = root;
507 REDBLACK_CK(is_black(child));
509 while((child != get_null()) && (cmp_obj(child, obj) != 0)){
510 rbt_nod_ref_t lft = get_left(child);
511 rbt_nod_ref_t rgt = get_right(child);
512 REDBLACK_CK(!is_red(child) || (!is_red(lft) && !is_red(rgt)));
515 if(cmp_obj(child, obj) > 0){
518 REDBLACK_CK(cmp_obj(child, obj) < 0);
522 if(child != get_null()){ last_found = child; }
526 template<
class node_manager_t>
528 redblack<node_manager_t>::left_rotate(rbt_nod_ref_t xx){
529 rbt_nod_ref_t yy = get_right(xx);
530 rbt_nod_ref_t yy_lft = get_left(yy);
532 REDBLACK_CK(check_refs(xx, 16));
533 REDBLACK_CK(check_refs(yy, 17));
535 get_right(xx) = yy_lft;
536 if(yy_lft != get_null()){
537 get_parent(yy_lft) = xx;
540 rbt_nod_ref_t parent_xx = get_parent(xx);
542 get_parent(yy) = parent_xx;
543 if(parent_xx == get_null()){
545 }
else if(xx == get_left(parent_xx)){
546 get_left(parent_xx) = yy;
548 REDBLACK_CK(xx == get_right(parent_xx));
549 get_right(parent_xx) = yy;
555 REDBLACK_CK(check_refs(parent_xx, 18));
556 REDBLACK_CK(check_refs(yy_lft, 19));
557 REDBLACK_CK(check_refs(xx, 20));
558 REDBLACK_CK(check_refs(yy, 21));
562 template<
class node_manager_t>
564 redblack<node_manager_t>::right_rotate(rbt_nod_ref_t yy){
565 rbt_nod_ref_t xx = get_left(yy);
566 rbt_nod_ref_t xx_rgt = get_right(xx);
568 REDBLACK_CK(check_refs(xx, 22));
569 REDBLACK_CK(check_refs(yy, 23));
571 get_left(yy) = xx_rgt;
572 if(xx_rgt != get_null()){
573 get_parent(xx_rgt) = yy;
576 rbt_nod_ref_t parent_yy = get_parent(yy);
578 get_parent(xx) = parent_yy;
579 if(parent_yy == get_null()){
581 }
else if(yy == get_right(parent_yy)){
582 get_right(parent_yy) = xx;
584 REDBLACK_CK(yy == get_left(parent_yy));
585 get_left(parent_yy) = xx;
591 REDBLACK_CK(check_refs(parent_yy, 24));
592 REDBLACK_CK(check_refs(xx_rgt, 25));
593 REDBLACK_CK(check_refs(xx, 26));
594 REDBLACK_CK(check_refs(yy, 27));
597 template<
class node_manager_t>
598 typename redblack<node_manager_t>::rbt_nod_ref_t
599 redblack<node_manager_t>::rbt_insert(rbt_obj_t
const & obj){
600 rbt_nod_ref_t parent = get_null();
601 rbt_nod_ref_t child = search_node(obj, parent);
602 if(child != get_null()){
606 rbt_nod_ref_t zz = create_node(obj);
607 REDBLACK_CK(zz != get_null());
608 REDBLACK_CK(check_refs(zz, 28));
610 get_parent(zz) = parent;
611 if(parent == get_null()){
613 }
else if(cmp_obj(parent, obj) > 0){
614 REDBLACK_CK(get_left(parent) == get_null());
615 get_left(parent) = zz;
617 REDBLACK_CK(cmp_obj(parent, obj) < 0);
618 REDBLACK_CK(get_right(parent) == get_null());
619 get_right(parent) = zz;
621 rbt_nod_ref_t created = zz;
622 REDBLACK_CK(check_refs(created, 29));
625 DBG_RBT(
int rotations = 0);
626 rbt_nod_ref_t xx = zz;
628 while((xx != root) && is_red(get_parent(xx))){
629 if(get_parent(xx) == get_left(get_grand(xx))){
630 rbt_nod_ref_t yy = get_right(get_grand(xx));
632 set_black(get_parent(xx));
634 set_red(get_grand(xx));
637 if(xx == get_right(get_parent(xx))){
640 DBG_RBT(rotations++);
642 REDBLACK_CK(xx == get_left(get_parent(xx)));
643 set_black(get_parent(xx));
644 set_red(get_grand(xx));
645 right_rotate(get_grand(xx));
646 REDBLACK_CK(is_black(get_parent(xx)));
647 DBG_RBT(rotations++);
650 REDBLACK_CK(get_parent(xx) == get_right(get_grand(xx)));
651 rbt_nod_ref_t yy = get_left(get_grand(xx));
653 set_black(get_parent(xx));
655 set_red(get_grand(xx));
658 if(xx == get_left(get_parent(xx))){
661 DBG_RBT(rotations++);
663 REDBLACK_CK(xx == get_right(get_parent(xx)));
664 set_black(get_parent(xx));
665 set_red(get_grand(xx));
666 left_rotate(get_grand(xx));
667 REDBLACK_CK(is_black(get_parent(xx)));
668 DBG_RBT(rotations++);
673 REDBLACK_CK(rotations <= 2);
674 insert_update_min_max(created);
675 REDBLACK_CK(check_refs(created, 30));
676 SLOW_REDBLACK_CK(check_min_max());
680 template<
class node_manager_t>
681 typename redblack<node_manager_t>::rbt_nod_ref_t
682 redblack<node_manager_t>::search_min(rbt_nod_ref_t xx){
683 if(xx == get_null()){
return xx; }
684 while(get_left(xx) != get_null()){
687 REDBLACK_CK(xx != get_null());
692 template<
class node_manager_t>
693 typename redblack<node_manager_t>::rbt_nod_ref_t
694 redblack<node_manager_t>::search_max(rbt_nod_ref_t xx){
695 if(xx == get_null()){
return xx; }
696 while(get_right(xx) != get_null()){
699 REDBLACK_CK(xx != get_null());
704 template<
class node_manager_t>
705 typename redblack<node_manager_t>::rbt_nod_ref_t
706 redblack<node_manager_t>::predecessor(rbt_nod_ref_t xx){
707 REDBLACK_CK(xx != get_null());
708 if(get_left(xx) != get_null()){
709 return search_max(get_left(xx));
711 rbt_nod_ref_t yy = get_parent(xx);
712 while((yy != get_null()) && (xx == get_left(yy))){
719 template<
class node_manager_t>
720 typename redblack<node_manager_t>::rbt_nod_ref_t
721 redblack<node_manager_t>::successor(rbt_nod_ref_t xx){
722 REDBLACK_CK(xx != get_null());
723 if(get_right(xx) != get_null()){
724 return search_min(get_right(xx));
726 rbt_nod_ref_t yy = get_parent(xx);
727 while((yy != get_null()) && (xx == get_right(yy))){
734 template<
class node_manager_t>
736 redblack<node_manager_t>::fix_remove(rbt_nod_ref_t xx, rbt_nod_ref_t parent){
737 DBG_RBT(
int rotations = 0);
738 while((xx != root) && is_black(xx)){
739 REDBLACK_CK(parent != get_null());
740 REDBLACK_CK((xx == get_null()) || (parent == get_parent(xx)));
741 if(xx == get_left(parent)){
742 DBG_RBT(
bool first_if =
false);
743 DBG(MARK_USED(first_if));
744 rbt_nod_ref_t ww = get_right(parent);
749 ww = get_right(parent);
750 DBG_RBT(first_if =
true);
751 DBG_RBT(rotations++);
753 if( is_black(get_left(ww)) &&
754 is_black(get_right(ww)) )
758 if(xx != root){ parent = get_parent(xx); }
759 else { parent = get_null(); }
760 REDBLACK_CK(!first_if || is_red(xx));
762 if(is_black(get_right(ww))){
763 rbt_nod_ref_t oldWw = ww;
765 REDBLACK_CK(is_red(get_left(ww)));
766 set_black(get_left(ww));
769 ww = get_right(parent);
770 REDBLACK_CK(get_right(ww) == oldWw);
771 DBG_RBT(rotations++);
773 REDBLACK_CK(is_red(get_right(ww)));
774 if(is_black(parent)){ set_black(ww); }
775 else { set_red(ww); }
777 set_black(get_right(ww));
781 DBG_RBT(rotations++);
784 DBG_RBT(
int first_if =
false);
785 DBG(MARK_USED(first_if));
786 REDBLACK_CK(xx == get_right(parent));
787 rbt_nod_ref_t ww = get_left(parent);
791 right_rotate(parent);
792 ww = get_left(parent);
793 DBG_RBT(first_if =
true);
794 DBG_RBT(rotations++);
796 if( is_black(get_right(ww)) &&
797 is_black(get_left(ww)) )
801 if(xx != root){ parent = get_parent(xx); }
802 else { parent = get_null(); }
803 REDBLACK_CK(!first_if || is_red(xx));
805 if(is_black(get_left(ww))){
806 rbt_nod_ref_t oldWw = ww;
808 REDBLACK_CK(is_red(get_right(ww)));
809 set_black(get_right(ww));
812 ww = get_left(parent);
813 REDBLACK_CK(get_left(ww) == oldWw);
814 DBG_RBT(rotations++);
816 REDBLACK_CK(is_red(get_left(ww)));
817 if(is_black(parent)){ set_black(ww); }
818 else { set_red(ww); }
820 set_black(get_left(ww));
821 right_rotate(parent);
824 DBG_RBT(rotations++);
829 REDBLACK_CK(rotations <= 3);
832 template<
class node_manager_t>
833 typename redblack<node_manager_t>::rbt_nod_ref_t
834 redblack<node_manager_t>::rbt_remove(rbt_nod_ref_t zz){
835 if(zz == get_null()){
return get_null(); }
836 REDBLACK_CK(zz != get_null());
837 REDBLACK_CK(check_refs(zz, 31));
838 remove_update_min_max(zz);
839 if(last_found == zz){
840 last_found = get_null();
843 rbt_nod_ref_t yy = get_null();
844 if( (get_left(zz) == get_null()) ||
845 (get_right(zz) == get_null()) )
853 rbt_nod_ref_t xx = get_null();
854 if(get_left(yy) != get_null()){
856 }
else if(get_right(yy) != get_null()){
860 rbt_nod_ref_t parent_yy = get_parent(yy);
862 if(xx != get_null()){ get_parent(xx) = parent_yy; }
863 if(parent_yy == get_null()){
865 }
else if(yy == get_left(parent_yy)){
866 get_left(parent_yy) = xx;
868 REDBLACK_CK(yy == get_right(parent_yy));
869 get_right(parent_yy) = xx;
871 if((yy != zz) && (yy != get_null())){
872 move_update_min_max(yy, zz);
873 get_obj(zz) = get_obj(yy);
875 if(is_black(yy)){ fix_remove(xx, parent_yy); }
876 get_right(yy) = get_null();
877 get_left(yy) = get_null();
878 get_parent(yy) = get_null();
880 SLOW_REDBLACK_CK(check_min_max());
884 template<
class node_manager_t>
886 redblack<node_manager_t>::print_rec(bj_ostream& os, rbt_nod_ref_t xx,
int tb,
887 bool& prev, rbt_nod_ref_t lst_nod,
int& tot,
888 int ctr,
bool just_cks)
891 if(xx == get_null()){
893 if(tot == 0){ tot = ctr; }
894 REDBLACK_CK((tot == 0) || (ctr == tot));
897 for(ii = 0; ii < tb; ii++){ os <<
"\t"; }
898 os <<
"#nil" << bj_eol;
903 char* cl = as_pt_char(
"");
904 if(is_black(xx)){ ctr++; cl = as_pt_char(
"#"); }
907 rbt_nod_ref_t rgt = get_right(xx);
908 REDBLACK_CK((rgt == get_null()) || (cmp(rgt, xx) > 0));
909 REDBLACK_CK((rgt == get_null()) || (get_parent(rgt) == xx));
910 REDBLACK_CK(!(is_red(xx) && is_red(rgt)));
911 print_rec(os, rgt, tb+1, prev, lst_nod, tot, ctr, just_cks);
915 for(ii = 0; ii < tb; ii++){ os <<
"\t"; }
918 REDBLACK_CK(check_refs(xx, 32));
919 char* min = as_pt_char(
"");
921 min = as_pt_char(
"<");
923 char* max = as_pt_char(
"");
925 max = as_pt_char(
">");
928 os << cl << min << get_obj(xx) << max << bj_eol;
931 if((lst_nod != get_null()) && (xx == lst_nod)){
936 rbt_nod_ref_t lft = get_left(xx);
937 REDBLACK_CK((lft == get_null()) || (cmp(lft, xx) < 0));
938 REDBLACK_CK((lft == get_null()) || (get_parent(lft) == xx));
939 REDBLACK_CK(!(is_red(xx) && is_red(lft)));
940 print_rec(os, lft, tb+1, prev, lst_nod, tot, ctr, just_cks);
944 template<
class node_manager_t>
946 redblack<node_manager_t>::print(bj_ostream& os,
bool just_chks,
953 os <<
"<HEAD>" << bj_eol;
954 os <<
"<TITLE>Sermo file</TITLE>" << bj_eol;
955 os <<
"</HEAD>" << bj_eol;
956 os <<
"<BODY>" << bj_eol;
957 os <<
"<PRE>" << bj_eol;
962 print_rec(os, root, 0, prev, last_found, total, 0, just_chks);
963 REDBLACK_CK((last_found == get_null()) || prev);
964 REDBLACK_CK(check_min_max());
967 os <<
"</PRE>" << bj_eol;
968 os <<
"</BODY>" << bj_eol;
973 template<
class node_manager_t>
975 redblack<node_manager_t>::check_order(){
976 redblack_iter<node_manager_t> iter1(*
this);
978 redblack<node_manager_t>::rbt_obj_t obj1;
979 redblack<node_manager_t>::rbt_obj_t obj2;
982 iter1.go_first_ref();
983 while(! iter1.in_null()){
985 obj2 = iter1.get_obj();
988 obj2 = iter1.get_obj();
989 comparison cc = cmp_objs(obj1, obj2);
991 abort_func(0, as_pt_char(
"check_failed !!!"));