hash method

int hash (Map<K, V> map)
override

Get a hashcode of an element.

The hashcode should be compatible with equals, so that if equals(a, b) then hash(a) == hash(b).

Implementation

int hash(Map<K, V> map) {
  if (map == null) return null.hashCode;
  int hash = 0;
  for (K key in map.keys) {
    int keyHash = _keyEquality.hash(key);
    int valueHash = _valueEquality.hash(map[key]);
    hash = (hash + 3 * keyHash + 7 * valueHash) & _HASH_MASK;
  }
  hash = (hash + (hash << 3)) & _HASH_MASK;
  hash ^= (hash >> 11);
  hash = (hash + (hash << 15)) & _HASH_MASK;
  return hash;
}