A destructor is present on this object, but not explicitly documented in the source.
A postblit is present on this object, but not explicitly documented in the source.
Add key/value to hash if key is not in table. value can be lazy/callable.
iterator by keys
iterator by key/value pairs
iterator by values
when capacity == 0 - next put for new key can trigger resize
throw away all keys
dump HashMap content to string (for debugging)
fetch is safe(do not return pointer) and nogc (do not throw exception) variant of "in" but retuns tuple("ok", "value"). You can check if result.ok == true. It this case you'll find value in "value"
get with default value it infers @safe, @nogc from user data: do not return ptr and do not thow
get value from hash or add if key is not in table. defaultValue can be callable.
get current grow factor.
set grow factor (can be between 2, 4 or 8).
get numter of keys in table
key in table
"in" is unsafe as it can point to arbitrary address after resize
mapk = v;
put pair (k,v) into hash.
remomve key from hash.
get current buckets number
Example
import std.range; import std.algorithm; import std.experimental.logger; HashMap!(string, int) counter; string[] words = [ "hello", "this", "simple", "example", "should", "succeed", "or", "it", "should", "fail" ]; // count words, simplest and fastest way foreach (word; words) { counter[word] = counter.getOrAdd(word, 0) + 1; } assert(!counter.fetch("world").ok); assert(counter.fetch("hello").value == 1); assert(counter["hello"] == 1); assert(counter["should"] == 2); assert(counter.contains("hello")); assert(counter.length == words.length - 1); // iterators assert(counter.byKey.count == counter.byValue.count); assert(words.all!(w => counter.contains(w))); // all words are in table assert(counter.byValue.sum == words.length); // sum of counters must equals to number of words