3
3
*
4
4
* Implementation of height balanced tree.
5
5
* Copyright (C) 2001-2004 Farooq Mela.
6
+ * Copyright (c) 2022 IBM Corporation. All rights reserved.
6
7
*
7
8
* $Id: hb_tree.c,v 1.10 2001/11/25 08:30:21 farooq Exp farooq $
8
9
*
@@ -51,6 +52,30 @@ static hb_node *node_max __P((hb_node *node));
51
52
static hb_node * node_next __P ((hb_node * node ));
52
53
static hb_node * node_prev __P ((hb_node * node ));
53
54
55
+ static dict * hb_dict_new __P ((dict_cmp_func key_cmp , dict_del_func key_del ,
56
+ dict_del_func dat_del ));
57
+ static dict_itor * hb_dict_itor_new __P ((hb_tree * tree ));
58
+ static void hb_itor_invalidate __P ((hb_itor * itor ));
59
+ static int hb_itor_first __P ((hb_itor * itor ));
60
+ static void * hb_itor_data __P ((hb_itor * itor ));
61
+ static const void * hb_itor_cdata __P ((const hb_itor * itor ));
62
+ static int hb_itor_last __P ((hb_itor * itor ));
63
+ static int hb_itor_nextn __P ((hb_itor * itor , unsigned count ));
64
+ static int hb_itor_prev __P ((hb_itor * itor ));
65
+ static int hb_itor_prevn __P ((hb_itor * itor , unsigned count ));
66
+ static int hb_itor_search __P ((hb_itor * itor , const void * key ));
67
+ static int hb_itor_set_data __P ((hb_itor * itor , void * dat , int del ));
68
+ static unsigned hb_tree_count __P ( (const hb_tree * tree ));
69
+ static void hb_tree_destroy __P ((hb_tree * tree , int del ));
70
+ static void hb_tree_empty __P ((hb_tree * tree , int del ));
71
+ static unsigned hb_tree_height __P ( (const hb_tree * tree ));
72
+ static const void * hb_tree_max __P ((const hb_tree * tree ));
73
+ static unsigned hb_tree_mheight __P ( (const hb_tree * tree ));
74
+ static const void * hb_tree_min __P ((const hb_tree * tree ));
75
+ static unsigned hb_tree_pathlen __P ( (const hb_tree * tree ));
76
+ static int hb_tree_probe __P ((hb_tree * tree , void * key , void * * dat ));
77
+ static void hb_tree_walk __P ((hb_tree * tree , dict_vis_func visit ));
78
+
54
79
hb_tree *
55
80
hb_tree_new (dict_cmp_func key_cmp , dict_del_func key_del ,
56
81
dict_del_func dat_del )
@@ -69,7 +94,7 @@ hb_tree_new(dict_cmp_func key_cmp, dict_del_func key_del,
69
94
return tree ;
70
95
}
71
96
72
- dict *
97
+ static dict *
73
98
hb_dict_new (dict_cmp_func key_cmp , dict_del_func key_del ,
74
99
dict_del_func dat_del )
75
100
{
@@ -98,7 +123,7 @@ hb_dict_new(dict_cmp_func key_cmp, dict_del_func key_del,
98
123
return dct ;
99
124
}
100
125
101
- void
126
+ static void
102
127
hb_tree_destroy (hb_tree * tree , int del )
103
128
{
104
129
ASSERT (tree != NULL );
@@ -109,7 +134,7 @@ hb_tree_destroy(hb_tree *tree, int del)
109
134
FREE (tree );
110
135
}
111
136
112
- void
137
+ static void
113
138
hb_tree_empty (hb_tree * tree , int del )
114
139
{
115
140
hb_node * node , * parent ;
@@ -236,7 +261,7 @@ hb_tree_insert(hb_tree *tree, void *key, void *dat, int overwrite)
236
261
return 0 ;
237
262
}
238
263
239
- int
264
+ static int
240
265
hb_tree_probe (hb_tree * tree , void * key , void * * dat )
241
266
{
242
267
int rv = 0 ;
@@ -402,7 +427,7 @@ hb_tree_remove(hb_tree *tree, const void *key, int del)
402
427
return 0 ;
403
428
}
404
429
405
- const void *
430
+ static const void *
406
431
hb_tree_min (const hb_tree * tree )
407
432
{
408
433
const hb_node * node ;
@@ -417,7 +442,7 @@ hb_tree_min(const hb_tree *tree)
417
442
return node -> key ;
418
443
}
419
444
420
- const void *
445
+ static const void *
421
446
hb_tree_max (const hb_tree * tree )
422
447
{
423
448
const hb_node * node ;
@@ -432,7 +457,7 @@ hb_tree_max(const hb_tree *tree)
432
457
return node -> key ;
433
458
}
434
459
435
- void
460
+ static void
436
461
hb_tree_walk (hb_tree * tree , dict_vis_func visit )
437
462
{
438
463
hb_node * node ;
@@ -446,31 +471,31 @@ hb_tree_walk(hb_tree *tree, dict_vis_func visit)
446
471
break ;
447
472
}
448
473
449
- unsigned
474
+ static unsigned
450
475
hb_tree_count (const hb_tree * tree )
451
476
{
452
477
ASSERT (tree != NULL );
453
478
454
479
return tree -> count ;
455
480
}
456
481
457
- unsigned
482
+ static unsigned
458
483
hb_tree_height (const hb_tree * tree )
459
484
{
460
485
ASSERT (tree != NULL );
461
486
462
487
return tree -> root ? node_height (tree -> root ) : 0 ;
463
488
}
464
489
465
- unsigned
490
+ static unsigned
466
491
hb_tree_mheight (const hb_tree * tree )
467
492
{
468
493
ASSERT (tree != NULL );
469
494
470
495
return tree -> root ? node_mheight (tree -> root ) : 0 ;
471
496
}
472
497
473
- unsigned
498
+ static unsigned
474
499
hb_tree_pathlen (const hb_tree * tree )
475
500
{
476
501
ASSERT (tree != NULL );
@@ -697,7 +722,7 @@ hb_itor_new(hb_tree *tree)
697
722
return itor ;
698
723
}
699
724
700
- dict_itor *
725
+ static dict_itor *
701
726
hb_dict_itor_new (hb_tree * tree )
702
727
{
703
728
dict_itor * itor ;
@@ -748,7 +773,7 @@ hb_itor_valid(const hb_itor *itor)
748
773
RETVALID (itor );
749
774
}
750
775
751
- void
776
+ static void
752
777
hb_itor_invalidate (hb_itor * itor )
753
778
{
754
779
ASSERT (itor != NULL );
@@ -768,7 +793,7 @@ hb_itor_next(hb_itor *itor)
768
793
RETVALID (itor );
769
794
}
770
795
771
- int
796
+ static int
772
797
hb_itor_prev (hb_itor * itor )
773
798
{
774
799
ASSERT (itor != NULL );
@@ -780,7 +805,7 @@ hb_itor_prev(hb_itor *itor)
780
805
RETVALID (itor );
781
806
}
782
807
783
- int
808
+ static int
784
809
hb_itor_nextn (hb_itor * itor , unsigned count )
785
810
{
786
811
ASSERT (itor != NULL );
@@ -798,7 +823,7 @@ hb_itor_nextn(hb_itor *itor, unsigned count)
798
823
RETVALID (itor );
799
824
}
800
825
801
- int
826
+ static int
802
827
hb_itor_prevn (hb_itor * itor , unsigned count )
803
828
{
804
829
ASSERT (itor != NULL );
@@ -816,7 +841,7 @@ hb_itor_prevn(hb_itor *itor, unsigned count)
816
841
RETVALID (itor );
817
842
}
818
843
819
- int
844
+ static int
820
845
hb_itor_first (hb_itor * itor )
821
846
{
822
847
hb_tree * t ;
@@ -828,7 +853,7 @@ hb_itor_first(hb_itor *itor)
828
853
RETVALID (itor );
829
854
}
830
855
831
- int
856
+ static int
832
857
hb_itor_last (hb_itor * itor )
833
858
{
834
859
hb_tree * t ;
@@ -840,7 +865,7 @@ hb_itor_last(hb_itor *itor)
840
865
RETVALID (itor );
841
866
}
842
867
843
- int
868
+ static int
844
869
hb_itor_search (hb_itor * itor , const void * key )
845
870
{
846
871
int rv ;
@@ -868,23 +893,23 @@ hb_itor_key(const hb_itor *itor)
868
893
return itor -> node ? itor -> node -> key : NULL ;
869
894
}
870
895
871
- void *
896
+ static void *
872
897
hb_itor_data (hb_itor * itor )
873
898
{
874
899
ASSERT (itor != NULL );
875
900
876
901
return itor -> node ? itor -> node -> dat : NULL ;
877
902
}
878
903
879
- const void *
904
+ static const void *
880
905
hb_itor_cdata (const hb_itor * itor )
881
906
{
882
907
ASSERT (itor != NULL );
883
908
884
909
return itor -> node ? itor -> node -> dat : NULL ;
885
910
}
886
911
887
- int
912
+ static int
888
913
hb_itor_set_data (hb_itor * itor , void * dat , int del )
889
914
{
890
915
ASSERT (itor != NULL );
0 commit comments