33 *
44 * Implementation of height balanced tree.
55 * Copyright (C) 2001-2004 Farooq Mela.
6+ * Copyright (c) 2022 IBM Corporation. All rights reserved.
67 *
78 * $Id: hb_tree.c,v 1.10 2001/11/25 08:30:21 farooq Exp farooq $
89 *
@@ -51,6 +52,30 @@ static hb_node *node_max __P((hb_node *node));
5152static hb_node * node_next __P ((hb_node * node ));
5253static hb_node * node_prev __P ((hb_node * node ));
5354
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+
5479hb_tree *
5580hb_tree_new (dict_cmp_func key_cmp , dict_del_func key_del ,
5681 dict_del_func dat_del )
@@ -69,7 +94,7 @@ hb_tree_new(dict_cmp_func key_cmp, dict_del_func key_del,
6994 return tree ;
7095}
7196
72- dict *
97+ static dict *
7398hb_dict_new (dict_cmp_func key_cmp , dict_del_func key_del ,
7499 dict_del_func dat_del )
75100{
@@ -98,7 +123,7 @@ hb_dict_new(dict_cmp_func key_cmp, dict_del_func key_del,
98123 return dct ;
99124}
100125
101- void
126+ static void
102127hb_tree_destroy (hb_tree * tree , int del )
103128{
104129 ASSERT (tree != NULL );
@@ -109,7 +134,7 @@ hb_tree_destroy(hb_tree *tree, int del)
109134 FREE (tree );
110135}
111136
112- void
137+ static void
113138hb_tree_empty (hb_tree * tree , int del )
114139{
115140 hb_node * node , * parent ;
@@ -236,7 +261,7 @@ hb_tree_insert(hb_tree *tree, void *key, void *dat, int overwrite)
236261 return 0 ;
237262}
238263
239- int
264+ static int
240265hb_tree_probe (hb_tree * tree , void * key , void * * dat )
241266{
242267 int rv = 0 ;
@@ -402,7 +427,7 @@ hb_tree_remove(hb_tree *tree, const void *key, int del)
402427 return 0 ;
403428}
404429
405- const void *
430+ static const void *
406431hb_tree_min (const hb_tree * tree )
407432{
408433 const hb_node * node ;
@@ -417,7 +442,7 @@ hb_tree_min(const hb_tree *tree)
417442 return node -> key ;
418443}
419444
420- const void *
445+ static const void *
421446hb_tree_max (const hb_tree * tree )
422447{
423448 const hb_node * node ;
@@ -432,7 +457,7 @@ hb_tree_max(const hb_tree *tree)
432457 return node -> key ;
433458}
434459
435- void
460+ static void
436461hb_tree_walk (hb_tree * tree , dict_vis_func visit )
437462{
438463 hb_node * node ;
@@ -446,31 +471,31 @@ hb_tree_walk(hb_tree *tree, dict_vis_func visit)
446471 break ;
447472}
448473
449- unsigned
474+ static unsigned
450475hb_tree_count (const hb_tree * tree )
451476{
452477 ASSERT (tree != NULL );
453478
454479 return tree -> count ;
455480}
456481
457- unsigned
482+ static unsigned
458483hb_tree_height (const hb_tree * tree )
459484{
460485 ASSERT (tree != NULL );
461486
462487 return tree -> root ? node_height (tree -> root ) : 0 ;
463488}
464489
465- unsigned
490+ static unsigned
466491hb_tree_mheight (const hb_tree * tree )
467492{
468493 ASSERT (tree != NULL );
469494
470495 return tree -> root ? node_mheight (tree -> root ) : 0 ;
471496}
472497
473- unsigned
498+ static unsigned
474499hb_tree_pathlen (const hb_tree * tree )
475500{
476501 ASSERT (tree != NULL );
@@ -697,7 +722,7 @@ hb_itor_new(hb_tree *tree)
697722 return itor ;
698723}
699724
700- dict_itor *
725+ static dict_itor *
701726hb_dict_itor_new (hb_tree * tree )
702727{
703728 dict_itor * itor ;
@@ -748,7 +773,7 @@ hb_itor_valid(const hb_itor *itor)
748773 RETVALID (itor );
749774}
750775
751- void
776+ static void
752777hb_itor_invalidate (hb_itor * itor )
753778{
754779 ASSERT (itor != NULL );
@@ -768,7 +793,7 @@ hb_itor_next(hb_itor *itor)
768793 RETVALID (itor );
769794}
770795
771- int
796+ static int
772797hb_itor_prev (hb_itor * itor )
773798{
774799 ASSERT (itor != NULL );
@@ -780,7 +805,7 @@ hb_itor_prev(hb_itor *itor)
780805 RETVALID (itor );
781806}
782807
783- int
808+ static int
784809hb_itor_nextn (hb_itor * itor , unsigned count )
785810{
786811 ASSERT (itor != NULL );
@@ -798,7 +823,7 @@ hb_itor_nextn(hb_itor *itor, unsigned count)
798823 RETVALID (itor );
799824}
800825
801- int
826+ static int
802827hb_itor_prevn (hb_itor * itor , unsigned count )
803828{
804829 ASSERT (itor != NULL );
@@ -816,7 +841,7 @@ hb_itor_prevn(hb_itor *itor, unsigned count)
816841 RETVALID (itor );
817842}
818843
819- int
844+ static int
820845hb_itor_first (hb_itor * itor )
821846{
822847 hb_tree * t ;
@@ -828,7 +853,7 @@ hb_itor_first(hb_itor *itor)
828853 RETVALID (itor );
829854}
830855
831- int
856+ static int
832857hb_itor_last (hb_itor * itor )
833858{
834859 hb_tree * t ;
@@ -840,7 +865,7 @@ hb_itor_last(hb_itor *itor)
840865 RETVALID (itor );
841866}
842867
843- int
868+ static int
844869hb_itor_search (hb_itor * itor , const void * key )
845870{
846871 int rv ;
@@ -868,23 +893,23 @@ hb_itor_key(const hb_itor *itor)
868893 return itor -> node ? itor -> node -> key : NULL ;
869894}
870895
871- void *
896+ static void *
872897hb_itor_data (hb_itor * itor )
873898{
874899 ASSERT (itor != NULL );
875900
876901 return itor -> node ? itor -> node -> dat : NULL ;
877902}
878903
879- const void *
904+ static const void *
880905hb_itor_cdata (const hb_itor * itor )
881906{
882907 ASSERT (itor != NULL );
883908
884909 return itor -> node ? itor -> node -> dat : NULL ;
885910}
886911
887- int
912+ static int
888913hb_itor_set_data (hb_itor * itor , void * dat , int del )
889914{
890915 ASSERT (itor != NULL );
0 commit comments