HashTable.remove

Removes the element with the key key.

The method returns the number of elements removed. Since the hash table contains only unique keys, remove always returns 1 if an element with the key was found, 0 otherwise.

struct HashTable(Key, Value, alias hasher = hash)
size_t
remove
(
Key key
)
if (
isHashFunction!(hasher, Key)
)

Parameters

key Key

The key to be removed.

Return Value

Type: size_t

Number of the removed elements.

Examples

HashTable!(string, int) hashTable;
hashTable["Euoplocephalus"] = 6;

assert("Euoplocephalus" in hashTable);
assert(hashTable.remove("Euoplocephalus") == 1);
assert(hashTable.remove("Euoplocephalus") == 0);
assert("Euoplocephalus" !in hashTable);

Meta