HashTable.byKey

Returns a bidirectional range that iterats over the keys of this $(D_PSYMBOL HashTable).

This function always returns a $(D_KEYWORD const) range, since changing a key of a hash table would probably change its hash value and require rehashing.

struct HashTable(Key, Value, alias hasher = hash)
const
byKey
()
if (
isHashFunction!(hasher, Key)
)

Return Value

Type: ByKey

$(D_KEYWORD const) bidirectional range that iterates over the keys of the container.

Examples

HashTable!(string, int) hashTable;
hashTable["one"] = 1;
hashTable["two"] = 2;

auto byKey = hashTable.byKey();
assert(!byKey.empty);

assert(byKey.front == "one" || byKey.front == "two");
assert(byKey.back == "one" || byKey.back == "two");
assert(byKey.front != byKey.back);

byKey.popFront();
assert(byKey.front == byKey.back);

byKey.popBack();
assert(byKey.empty);

See Also

$(D_PSYMBOL byValue).

Meta