smjg.libs.util.hashmap
This module provides a hash map container template.
- template HashMap(K,V)
Convenience alias for smjg.libs.util.hashmap.THashMap!(K, V).Map.
- template THashMap(K,V)
- Future Directions:
- The map class will likely be defined directly as HashMap, with iterator or range classes as nested classes. THashMap will then be deprecated.
- class Map;
The Map class implements an associative container.
Unlike the current implementation of D's built-in associative arrays, this doesn't rely on an ordering comparator, so it will work even if the key type has no ordering or unequal objects can rank equally in order.
- Future Directions:
- Map will enforce immutability of the key type. An abstract base class similar to Set will probably be set up for generality.
- const V opIndex(K k);
- Returns:
- the value with key k, or V.init if the key is not present.
- V opIndexAssign(V v, K k);
Sets the value with key k to be v.
- bool opIn_r(K k);
- Returns:
- whether the map contains key k.
- V remove(K k);
Removes the key k.
- Returns:
- the value that was associated with this key, or V.init if k it was not present.
- size_t length();
- Returns:
- the number of keys stored in the map.
- Map rehash();
Rehashes the array in place.
- Returns:
- the array.
- int opApply(int delegate(ref V) dg);
const int opApply(int delegate(ref const(V)) dg);
int opApply(int delegate(ref const(K), ref V) dg);
const int opApply(int delegate(ref const(K), ref const(V)) dg); Iterates over the (keys and) values in the map.
Modifying the map while foreach is in progress, other than by a ref value variable in the foreach loop, currently leads to undefined behaviour.
- class MapIterator;
The MapIterator class is used to iterate over the elements of a HashMap.
Modifying the map, other than by the iterator's value property, and then continuing to use the iterator, currently leads to undefined behaviour.
- this(Map m);
Constructs a new iterator over m.
- K key();
The key associated with the iterator's current position.
- Precondition:
- The iterator must not be at the end.
- V value();
V value(V v); The value associated with the iterator's current position.
- Precondition:
- The iterator must not be at the end.
- void opPostInc();
Advances the iterator.
- bool atEnd();
- Returns:
- whether the iterator has reached the terminal position following the final key in the map.