The universal hash function used by Set and Dictionary.

    @frozen struct Hasher

    Hasher can be used to map an arbitrary sequence of bytes to an integer hash value. You can feed data to the hasher using a series of calls to mutating combine methods. When you’ve finished feeding the hasher, the hash value can be retrieved by calling finalize():

    var hasher = Hasher()
    let hashValue = hasher.finalize()

    Within the execution of a Swift program, Hasher guarantees that finalizing it will always produce the same hash value as long as it is fed the exact same sequence of bytes. However, the underlying hash algorithm is designed to exhibit avalanche effects: slight changes to the seed or the input byte sequence will typically produce drastic changes in the generated hash value.

    Citizens in Swift


    • protocol Sendable

      A type whose values can safely be passed across concurrency domains by copying.