Undocumented in source.
Use the given allocator for allocations.
Constructs an HashMap with an initial bucket count of bucketCount. bucketCount must be a power of two.
Constructs an HashMap with an initial bucket count of bucketCount. bucketCount must be a power of two.
Undocumented in source.
Undocumented in source.
Gets the value for the given key, or returns defaultValue if the given key is not present.
Support for foreach(key, value; aa) { ... } syntax;
Supports key in aa syntax.
Supports aakey syntax.
Supports aakey = value; syntax.
Removes the value associated with the given key
1 import std.uuid : randomUUID; 2 auto hm = HashMap!(string, int)(16); 3 assert (hm.length == 0); 4 assert (!hm.remove("abc")); 5 hm["answer"] = 42; 6 assert (hm.length == 1); 7 assert ("answer" in hm); 8 hm.remove("answer"); 9 assert (hm.length == 0); 10 hm["one"] = 1; 11 hm["one"] = 1; 12 assert (hm.length == 1); 13 assert (hm["one"] == 1); 14 foreach (i; 0 .. 1000) 15 { 16 hm[randomUUID().toString] = i; 17 } 18 assert (hm.length == 1001); 19 assert (hm.keys().length == hm.length); 20 assert (hm.values().length == hm.length); 21 foreach (ref string k, ref int v; hm) {} 22 23 auto hm2 = HashMap!(char, char)(4); 24 hm2['a'] = 'a'; 25 26 HashMap!(int, int) hm3; 27 assert (hm3.get(100, 20) == 20); 28 hm3[100] = 1; 29 assert (hm3.get(100, 20) == 1);
Associative array / hash map.