Constructor.
Constructor.
Calculates the hash value from key. Uses the identity since key is expected to be a suitable hash value.
type to store in values of map
// Unittest that serves as a usage example static immutable expected_number_of_elements = 1_000; // Mapping from hash_t -> int auto map = new HashMap!(int)(expected_number_of_elements); hash_t hash = 232323; // Add a mapping *(map.put(hash)) = 12; // Look up a mapping and obtain a pointer to the value if found or null // if not found; int* val = hash in map; bool exists = val !is null; // Remove a mapping map.remove(hash); // Clear the map map.clear(); // Mapping from hash_t -> char[] auto map2 = new HashMap!(char[])(expected_number_of_elements); // Add a mapping char[]* val2 = map2.put(hash); (*val2).length = "hello".length; (*val2)[] = "hello"; // Mapping from hash_t -> struct struct MyStruct { int x; float y; } auto map3 = new HashMap!(MyStruct)(expected_number_of_elements); // Add a mapping, put() never returns null with (*map3.put(hash)) { x = 12; y = 23.23; }
HashMap class template. Manages a mapping from hash_t to the specified type.