MapReserve
Description
Reserve enough probe slots for at least n entries.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Hash map. |
n |
in | Minimum number of entries expected. |
Success
Returns true. The probe table now has capacity for at least n entries without triggering a rehash. Existing entries are preserved (a rehash into the larger table is performed if growth was needed). Map length is unchanged.
Failure
Returns false on allocation failure. The map is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Memory.h:75:
#define MapMustReserve(m, n) \
do { \
if (!MapReserve((m), (n))) { \
LOG_FATAL("MapMustReserve failed"); \
} \- In
Init.c:61:
size reserved_capacity;
MapReserve(&map, 32);
reserved_capacity = (size)MapCapacity(&map);- In
Init.c:170:
// Force a growth-driven rehash. Existing entries must survive it,
// length must be unchanged, and capacity must grow to at least 64.
result = MapReserve(&map, 64);
result = result && (MapCapacity(&map) >= 64);
result = result && (MapPairCount(&map) == 8);- In
Insert.c:1065:
bool result = (MapCapacity(&map) == 42);
bool reserved = MapReserve(&map, 100);
result = result && reserved;
result = result && (MapCapacity(&map) >= 100);- In
Access.c:94:
IntIntMap map = MapInitWithPolicy(const_hash, i32_compare, policy, &alloc);
MapReserve(&map, 200);
for (int k = 0; k < 60; k++)- In
Access.c:126:
IntIntMap map = MapInitWithPolicy(const_hash, i32_compare, policy, &alloc);
MapReserve(&map, 6);
for (int k = 10; k <= 15; k++)
MapInsertR(&map, k, k);
Last updated on