diff options
author | Eric Anholt <eric@anholt.net> | 2012-11-06 16:54:12 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2012-11-06 17:26:52 -0800 |
commit | c2a4a1c274559d479ec14bea8f412e422db6b6b5 (patch) | |
tree | c67f97207d164555b1d73643a7ddf02785b75b27 | |
parent | 642faf7475edc78d59086ad859ef734482ca275c (diff) |
Add a note why hash_table_random_entry() may be of use.
-rw-r--r-- | hash_table.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/hash_table.c b/hash_table.c index 209a4bd..a162bc4 100644 --- a/hash_table.c +++ b/hash_table.c @@ -319,6 +319,14 @@ hash_table_next_entry(struct hash_table *ht, struct hash_entry *entry) return NULL; } +/** + * Returns a random entry from the hash table. + * + * This may be useful in implementing random replacement (as opposed + * to just removing everything) in caches based on this hash table + * implementation. @predicate may be used to filter entries, or may + * be set to NULL for no filtering. + */ struct hash_entry * hash_table_random_entry(struct hash_table *ht, int (*predicate)(struct hash_entry *entry)) |