02110-1301, USA. */
#include <config.h>
+#include <stdbool.h>
#include "hash.h"
#include "message.h"
#include <assert.h>
#endif
}
-/* A "algo_predicate_func" that returns nonzero if DATA points
+/* A "algo_predicate_func" that returns true if DATA points
to a non-null void. */
-static int
+static bool
not_null (const void *data_, void *aux UNUSED)
{
void *const *data = data_;
}
/* Deletes the entry in hash table H that matches TARGET.
- Returns nonzero if an entry was deleted.
+ Returns true if an entry was deleted.
Uses Knuth's Algorithm 6.4R (Deletion with linear probing).
Because our load factor is at most 1/2, the average number of
moves that this algorithm makes should be at most 2 - ln 2 ~=
1.65. */
-int
+bool
hsh_delete (struct hsh_table *h, const void *target)
{
unsigned i = locate_matching_entry (h, target);
{
i = (i - 1) & (h->size - 1);
if (h->entries[i] == NULL)
- return 1;
+ return true;
r = h->hash (h->entries[i], h->aux) & (h->size - 1);
}
}
}
else
- return 0;
+ return false;
}
\f
/* Iteration. */