HashTable.opIndex - multiple declarations

Function HashTable.opIndex

Find the element with the key key.

ref Value opIndex(T) (
  auto const ref T key
)
if (ifTestable!(T, (a) => Key.init == a));

Parameters

NameDescription
T Type comparable with the key type, used for the lookup.
key The key to be find.

Returns

The value associated with key.

Precondition

Element with key is in this hash table.

Example

HashTable!(string, int) hashTable;
hashTable["Triceratops"] = 7;
assert(hashTable["Triceratops"] == 7);

Function HashTable.opIndex

Returns a bidirectional range whose element type is a tuple of a key and the respective value.

HashTable.Range opIndex();

HashTable.ConstRange opIndex() const;

Returns

A bidirectional range that iterates over the container.

Example

HashTable!(string, int) hashTable;
assert(hashTable[].empty);

hashTable["Iguanodon"] = 9;
assert(!hashTable[].empty);
assert(hashTable[].front == hashTable.KeyValue("Iguanodon", 9));
assert(hashTable[].back == hashTable.KeyValue("Iguanodon", 9));