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 <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Mar 23, 2017 at 13:47 UTC
4f4458aafa809e184358256e35fd90c227dba81d
1 file changed
+22
Documentation/technical/api-hashmap.txt
+22
@@ -21,6 +21,9 @@ that the hashmap is initialized. It may also be useful for statistical purposes
21
`cmpfn` stores the comparison function specified in `hashmap_init()`. In
22
advanced scenarios, it may be useful to change this, e.g. to switch between
23
case-sensitive and case-insensitive lookup.
24
++
25
+When `disallow_rehash` is set, automatic rehashes are prevented during inserts
26
+and deletes.
27
28
`struct hashmap_entry`::
29
@@ -57,6 +60,7 @@ Functions
60
`unsigned int strihash(const char *buf)`::
61
`unsigned int memhash(const void *buf, size_t len)`::
62
`unsigned int memihash(const void *buf, size_t len)`::
63
+`unsigned int memihash_cont(unsigned int hash_seed, const void *buf, size_t len)`::
64
65
Ready-to-use hash functions for strings, using the FNV-1 algorithm (see
66
http://www.isthe.com/chongo/tech/comp/fnv).
@@ -65,6 +69,9 @@ Functions
69
`memihash` operate on arbitrary-length memory.
70
+
71
`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.
75
76
`unsigned int sha1hash(const unsigned char *sha1)`::
77
@@ -184,6 +191,21 @@ passed to `hashmap_cmp_fn` to decide whether the entry matches the key.
191
+
192
Returns the removed entry, or NULL if not found.
193
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
+
209
`void hashmap_iter_init(struct hashmap *map, struct hashmap_iter *iter)`::
210
`void *hashmap_iter_next(struct hashmap_iter *iter)`::
211
`void *hashmap_iter_first(struct hashmap *map, struct hashmap_iter *iter)`::