diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-10-25 18:18:26 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-10-25 18:18:26 -0400 |
commit | 4531818f12221fdedba9f6f4913d22228628328c (patch) | |
tree | 60bed7efe713cce5a840914938bef998e0c9ae0c /src/shared/set.h | |
parent | ac2d134b8c27629754463d505b2aaab3c99c71c6 (diff) |
hashmap: introduce hashmap_reserve()
With the current hashmap implementation that uses chaining, placing a
reservation can serve two purposes:
- To optimize putting of entries if the number of entries to put is
known. The reservation allocates buckets, so later resizing can be
avoided.
- To avoid having very long bucket chains after using
hashmap_move(_one).
In an alternative hashmap implementation it will serve an additional
purpose:
- To guarantee a subsequent hashmap_move(_one) will not fail with
-ENOMEM (this never happens in the current implementation).
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared/set.h')
-rw-r--r-- | src/shared/set.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/shared/set.h b/src/shared/set.h index f1111d1bc8..ae3090a09f 100644 --- a/src/shared/set.h +++ b/src/shared/set.h @@ -37,6 +37,8 @@ int set_put(Set *s, void *value); void *set_get(Set *s, void *value); bool set_contains(Set *s, void *value); +int set_reserve(Set *s, unsigned entries_add); + void *set_iterate(Set *s, Iterator *i); DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free); |