From b457ace1eed823e5822884872034b42aa8a77b7f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 8 Dec 2018 15:25:51 +0100 Subject: [PATCH] Fix comments. * lib/gl_list.h (gl_list_free): Clarify what it does. * lib/gl_oset.h (gl_oset_free): Likewise. * lib/gl_set.h (gl_set_free): Likewise. * lib/gl_anytree_oset.h (gl_tree_search_atleast): Fix typo in comment. * lib/gl_array_oset.c (gl_array_search_atleast): Likewise. * lib/gl_anyavltree_list1.h (MAXHEIGHT): Likewise. * lib/gl_avltree_oset.c (MAXHEIGHT): Likewise. --- ChangeLog | 11 +++++++++++ lib/gl_anyavltree_list1.h | 8 ++++---- lib/gl_anytree_oset.h | 2 +- lib/gl_array_oset.c | 2 +- lib/gl_avltree_oset.c | 8 ++++---- lib/gl_list.h | 4 +++- lib/gl_oset.h | 3 ++- lib/gl_set.h | 3 ++- 8 files changed, 28 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd31719896..70e269d884 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2018-12-08 Bruno Haible + + Fix comments. + * lib/gl_list.h (gl_list_free): Clarify what it does. + * lib/gl_oset.h (gl_oset_free): Likewise. + * lib/gl_set.h (gl_set_free): Likewise. + * lib/gl_anytree_oset.h (gl_tree_search_atleast): Fix typo in comment. + * lib/gl_array_oset.c (gl_array_search_atleast): Likewise. + * lib/gl_anyavltree_list1.h (MAXHEIGHT): Likewise. + * lib/gl_avltree_oset.c (MAXHEIGHT): Likewise. + 2018-12-03 Bruno Haible hash-set: Add tests. diff --git a/lib/gl_anyavltree_list1.h b/lib/gl_anyavltree_list1.h index a65b4a027a..d5a491b63b 100644 --- a/lib/gl_anyavltree_list1.h +++ b/lib/gl_anyavltree_list1.h @@ -62,9 +62,9 @@ struct gl_list_impl struct gl_list_node_impl *root; /* root node or NULL */ }; -/* An AVL tree of height h has at least F_(h+2) [Fibonacci number] and at most - 2^h - 1 elements. So, h <= 84 (because a tree of height h >= 85 would have - at least F_87 elements, and because even on 64-bit machines, - sizeof (gl_list_node_impl) * F_87 > 2^64 +/* An AVL tree of height h has at least F_(h+2) - 1 [Fibonacci number] and at + most 2^h - 1 elements. So, h <= 84 (because a tree of height h >= 85 would + have at least F_87 - 1 elements, and because even on 64-bit machines, + sizeof (gl_list_node_impl) * (F_87 - 1) > 2^64 this would exceed the address space of the machine. */ #define MAXHEIGHT 83 diff --git a/lib/gl_anytree_oset.h b/lib/gl_anytree_oset.h index ee71f5e0a3..8adf645c3f 100644 --- a/lib/gl_anytree_oset.h +++ b/lib/gl_anytree_oset.h @@ -91,7 +91,7 @@ gl_tree_search_atleast (gl_oset_t set, node = node->right; else { - /* We have an element >= VALUE. But we need the leftmost such + /* We have an element >= THRESHOLD. But we need the leftmost such element. */ gl_oset_node_t found = node; node = node->left; diff --git a/lib/gl_array_oset.c b/lib/gl_array_oset.c index bd4f8d3874..f8b2bc1681 100644 --- a/lib/gl_array_oset.c +++ b/lib/gl_array_oset.c @@ -136,7 +136,7 @@ gl_array_search_atleast (gl_oset_t set, minimal such index. */ high = mid; /* At each loop iteration, low <= high and - compar (list->elements[high], value) >= 0, + compar (set->elements[high], threshold) >= 0, and we know that the first occurrence of the element is at low <= position <= high. */ while (low < high) diff --git a/lib/gl_avltree_oset.c b/lib/gl_avltree_oset.c index 45aadcc609..ead337c0e1 100644 --- a/lib/gl_avltree_oset.c +++ b/lib/gl_avltree_oset.c @@ -59,10 +59,10 @@ struct gl_oset_impl size_t count; /* number of nodes */ }; -/* An AVL tree of height h has at least F_(h+2) [Fibonacci number] and at most - 2^h - 1 elements. So, h <= 84 (because a tree of height h >= 85 would have - at least F_87 elements, and because even on 64-bit machines, - sizeof (gl_oset_node_impl) * F_87 > 2^64 +/* An AVL tree of height h has at least F_(h+2) - 1 [Fibonacci number] and at + most 2^h - 1 elements. So, h <= 84 (because a tree of height h >= 85 would + have at least F_87 - 1 elements, and because even on 64-bit machines, + sizeof (gl_oset_node_impl) * (F_87 - 1) > 2^64 this would exceed the address space of the machine. */ #define MAXHEIGHT 83 diff --git a/lib/gl_list.h b/lib/gl_list.h index f050fe6d73..66d1ad904a 100644 --- a/lib/gl_list.h +++ b/lib/gl_list.h @@ -333,7 +333,9 @@ extern bool gl_list_remove_at (gl_list_t list, size_t position); extern bool gl_list_remove (gl_list_t list, const void *elt); /* Free an entire list. - (But this call does not free the elements of the list.) */ + (But this call does not free the elements of the list. It only invokes + the DISPOSE_FN on each of the elements of the list, and only if the list + is not a sublist.) */ extern void gl_list_free (gl_list_t list); #endif /* End of inline and gl_xlist.h-defined functions. */ diff --git a/lib/gl_oset.h b/lib/gl_oset.h index abe3eb4a61..366a95b871 100644 --- a/lib/gl_oset.h +++ b/lib/gl_oset.h @@ -144,7 +144,8 @@ extern int gl_oset_nx_add (gl_oset_t set, const void *elt) extern bool gl_oset_remove (gl_oset_t set, const void *elt); /* Free an entire ordered set. - (But this call does not free the elements of the set.) */ + (But this call does not free the elements of the set. It only invokes + the DISPOSE_FN on each of the elements of the set.) */ extern void gl_oset_free (gl_oset_t set); #endif /* End of inline and gl_xoset.h-defined functions. */ diff --git a/lib/gl_set.h b/lib/gl_set.h index bc615c3d8e..b3578ba2e1 100644 --- a/lib/gl_set.h +++ b/lib/gl_set.h @@ -136,7 +136,8 @@ extern int gl_set_nx_add (gl_set_t set, const void *elt) extern bool gl_set_remove (gl_set_t set, const void *elt); /* Free an entire set. - (But this call does not free the elements of the set.) */ + (But this call does not free the elements of the set. It only invokes + the DISPOSE_FN on each of the elements of the set.) */ extern void gl_set_free (gl_set_t set); #endif /* End of inline and gl_xset.h-defined functions. */ -- 2.39.5