Constructor.
Returns the internal associative array, for when the wrapper is insufficient.
Clears the internal associative array and all counters.
Duplicates this. Explicitly copies the internal associative array.
Returns the length of the internal associative array.
Bumps the internal counter of new keys since the last rehash, and depending on the resulting value of it, maybe rehashes.
The number of new entries that has been added since the last rehash. Accessor.
The number of times this instance has rehashed itself. Accessor.
Inherit a native associative array into aa.
Wraps key in aa to the internal associative array.
Allows for casting this into the base associative array type.
Assigns a value into the internal associative array. If it created a new entry, then call maybeRehash to bump the internal counter and maybe rehash.
Rehashes the internal associative array, bumping the rehash counter and zeroing the keys-added counter. Additionally invokes the onRehashDg delegate.
Removes a key from the aa associative array by merely invoking .remove.
The minimum number of additions needed before the first rehash takes place.
Delegate called when rehashing takes place.
The modifier by how much more entries must be added before another rehash takes place, with regards to the current aa length.
import std.conv : to; RehashingAA!(string, int) aa; aa.minimumNeededForRehash = 2; aa["abc"] = 123; aa["def"] = 456; assert((aa.newKeysSinceLastRehash == 2), aa.newKeysSinceLastRehash.to!string); assert((aa.numRehashes == 0), aa.numRehashes.to!string); aa["ghi"] = 789; assert((aa.numRehashes == 1), aa.numRehashes.to!string); assert((aa.newKeysSinceLastRehash == 0), aa.newKeysSinceLastRehash.to!string); aa.rehash(); assert((aa.numRehashes == 2), aa.numRehashes.to!string); auto realAA = cast(int[string])aa; assert("abc" in realAA); assert("def" in realAA); assert("ghi" in realAA); assert("jkl" !in realAA); auto aa2 = aa.dup; aa2["jkl"] = 123; assert("jkl" in aa2); assert("jkl" !in aa);
A wrapper around a native associative array that you can controllably set to automatically rehash as entries are added.