hash method
Creates a combined hash code for a number of objects.
The hash code is computed for all arguments that are actually
supplied, even if they are null
, by numerically combining the
Object.hashCode of each argument.
Example:
class SomeObject {
final Object a, b, c;
SomeObject(this.a, this.b, this.c);
bool operator ==(Object other) =>
other is SomeObject && a == other.a && b == other.b && c == other.c;
int get hashCode => Object.hash(a, b, c);
}
The computed value will be consistent when the function is called with the same arguments multiple times during the execution of a single program.
The hash value generated by this function is not guaranteed to be stable over different runs of the same program, or between code run in different isolates of the same program. The exact algorithm used may differ between different platforms, or between different versions of the platform libraries, and it may depend on values that change on each program execution.
The hashAll function gives the same result as this function when called with a collection containing the actual arguments to this function in the same order.
Implementation
@override
int hash(Map<K, V>? map) {
if (map == null) {
return null.hashCode;
}
int hash = 0;
for (final K key in map.keys) {
final int keyHash = _keyEquality.hash(key);
final int valueHash = _valueEquality.hash(map[key] as V);
hash = (hash + 3 * keyHash + 7 * valueHash) & _hashMask;
}
hash = (hash + (hash << 3)) & _hashMask;
hash ^= hash >> 11;
hash = (hash + (hash << 15)) & _hashMask;
return hash;
}