StringMap.reserve

Reserves capacity for an associative array. The capacity is the size that the underlaying slices can grow to before the underlying arrays may be reallocated or extended.

struct StringMap(T, U = uint)
@trusted pure nothrow
size_t
reserve
()
()
if (
isMutable!T &&
!__traits(hasMember, T, "opPostMove")
&&
__traits(isUnsigned, U)
)

Examples

StringMap!double map;
auto capacity = map.reserve(10);
assert(capacity >= 10);
assert(map.capacity == capacity);
map["c"] = 4.0;
assert(map.capacity == capacity);
map["a"] = 3.0;
assert(map.capacity >= 2);
assert(map.remove("c"));
capacity = map.reserve(20);
assert(capacity >= 20);
assert(map.capacity == capacity);

Meta