keyHash
Computes the hash code used to look up a key in a dictionary.
Category: Language Fundamentals > Data Types
Syntax
h = keyHash(key)
Returns a uint64 hash value for key.
Description
A dictionary uses keyHash to find the slot for a key quickly, and then keyMatch to confirm the hit, since different keys can share a hash. The exact numbers are an implementation detail and may differ between releases, so compare hashes only with each other and never store them.
A class that defines its own keyHash and keyMatch methods can be used as a dictionary key.
Input arguments
key- A key value: numeric, text, datetime, and other supported types.
Output arguments
huint64scalar. Equal keys always give equal hashes.
Example
Equal keys, equal hashes
keyHash('abc') == keyHash('abc')
class(keyHash(42))
Output
ans = logical
1
ans = 'uint64'