Skip to content

Commit 4f4458a

Browse files
jeffhostetlergitster
authored andcommitted
hashmap: document memihash_cont, hashmap_disallow_rehash api
Document memihash_cont() and hashmap_disallow_rehash() in Documentation/technical/api-hashmap.txt. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0607e10 commit 4f4458a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Documentation/technical/api-hashmap.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ that the hashmap is initialized. It may also be useful for statistical purposes
2121
`cmpfn` stores the comparison function specified in `hashmap_init()`. In
2222
advanced scenarios, it may be useful to change this, e.g. to switch between
2323
case-sensitive and case-insensitive lookup.
24+
+
25+
When `disallow_rehash` is set, automatic rehashes are prevented during inserts
26+
and deletes.
2427

2528
`struct hashmap_entry`::
2629

@@ -57,6 +60,7 @@ Functions
5760
`unsigned int strihash(const char *buf)`::
5861
`unsigned int memhash(const void *buf, size_t len)`::
5962
`unsigned int memihash(const void *buf, size_t len)`::
63+
`unsigned int memihash_cont(unsigned int hash_seed, const void *buf, size_t len)`::
6064

6165
Ready-to-use hash functions for strings, using the FNV-1 algorithm (see
6266
http://www.isthe.com/chongo/tech/comp/fnv).
@@ -65,6 +69,9 @@ Functions
6569
`memihash` operate on arbitrary-length memory.
6670
+
6771
`strihash` and `memihash` are case insensitive versions.
72+
+
73+
`memihash_cont` is a variant of `memihash` that allows a computation to be
74+
continued with another chunk of data.
6875

6976
`unsigned int sha1hash(const unsigned char *sha1)`::
7077

@@ -184,6 +191,21 @@ passed to `hashmap_cmp_fn` to decide whether the entry matches the key.
184191
+
185192
Returns the removed entry, or NULL if not found.
186193

194+
`void hashmap_disallow_rehash(struct hashmap *map, unsigned value)`::
195+
196+
Disallow/allow automatic rehashing of the hashmap during inserts
197+
and deletes.
198+
+
199+
This is useful if the caller knows that the hashmap will be accessed
200+
by multiple threads.
201+
+
202+
The caller is still responsible for any necessary locking; this simply
203+
prevents unexpected rehashing. The caller is also responsible for properly
204+
sizing the initial hashmap to ensure good performance.
205+
+
206+
A call to allow rehashing does not force a rehash; that might happen
207+
with the next insert or delete.
208+
187209
`void hashmap_iter_init(struct hashmap *map, struct hashmap_iter *iter)`::
188210
`void *hashmap_iter_next(struct hashmap_iter *iter)`::
189211
`void *hashmap_iter_first(struct hashmap *map, struct hashmap_iter *iter)`::

0 commit comments

Comments
 (0)