Main Content

keyHash

Generate hash code for dictionary key

Since R2022b

    Description

    example

    h = keyHash(A) returns uint64 scalar that represents the input array, A.

    The keyHash function generates hash code based on the properties of the input. For custom classes keyHash may need to be overloaded to ensure correct equivalence. For more information on using custom classes with dictionary, see Dictionaries and Custom Classes

    Note

    keyHash uses a random seed. Results are not reproducible between MATLAB Sessions or across parallel workers.

    Examples

    collapse all

    Use keyHash to create hash code for several arrays.

    h = keyHash([1 2 3 4])
    h =
    
      uint64
    
       15176618535206774870
    h = keyHash(["monocyle" "bicycle" "tricyle"])
    h =
    
      uint64
    
       680190522706874070

    Input Arguments

    collapse all

    Input array of dictionary keys, specified as an array.

    Output Arguments

    collapse all

    Hash code, specified as a uint64 scalar.

    Version History

    Introduced in R2022b