Key.toHash

size_t toHash() const;

Computes a hash of the key material for use as an associative array key.

Implementations should hash the algorithm name and encoded key bytes.

Important: these interface methods alone do NOT integrate with D's built-in associative arrays or the `==` operator. AAs keyed on class types and a == b dispatch through the non-const Object virtuals, so an implementation that only defines this interface method silently falls back to identity hashing/equality. Implementations MUST also declare

override size_t toHash() @trusted nothrow
override bool opEquals(Object o)

forwarding to these interface methods, which is what makes Key[...] AAs and `==` behave per this contract.

Note

toHash and opEquals must be consistent: if opEquals(a, b)

returns true, then toHash(a) must equal toHash(b). Violating this contract causes undefined behavior in associative arrays, including potential AA corruption and lost entries.

Returns

A hash value suitable for associative array indexing.