HashTable.opIndex

Find the element with the key key.

  1. Value opIndex(T key)
    struct HashTable(Key, Value, alias hasher = hash)
    ref
    Value
    opIndex
    (
    T
    )
    (
    auto ref const T key
    )
    if (
    ifTestable!(T, a => Key.init == a)
    )
    if (
    isHashFunction!(hasher, Key)
    )
  2. Range opIndex()
  3. ConstRange opIndex()

Parameters

T

Type comparable with the key type, used for the lookup.

key T

The key to be find.

Return Value

Type: Value

The value associated with key.

Precondition: Element with key is in this hash table.

Examples

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

Meta