hash method

*<Null safety>*
  • @override

int hash (List<E>? list) override

Implementation

@override
int hash(List<E>? list) {
  if (list == null) return null.hashCode;
  // Jenkins's one-at-a-time hash function.
  // This code is almost identical to the one in IterableEquality, except
  // that it uses indexing instead of iterating to get the elements.
  var hash = 0;
  for (var i = 0; i < list.length; i++) {
    var c = _elementEquality.hash(list[i]);
    hash = (hash + c) & _HASH_MASK;
    hash = (hash + (hash << 10)) & _HASH_MASK;
    hash ^= (hash >> 6);
  }
  hash = (hash + (hash << 3)) & _HASH_MASK;
  hash ^= (hash >> 11);
  hash = (hash + (hash << 15)) & _HASH_MASK;
  return hash;
}