same method

  1. @override
bool same(
  1. IMap<K, V>? other
)
override

Will return true if the maps internals are the same instances (comparing by identity). This will be fast even for very large maps, since it doesn't compare each entry.

May can also return true under some other situations where it's very cheap to determine that the maps are equal even if the maps internals are NOT the same.

Note: This is not the same as identical(map1, map2) since it doesn't compare the maps themselves, but their internal state. Comparing the internal state is better, because it will return true more often.

Implementation

@override
bool same(IMap<K, V>? other) =>
    (other != null) &&
    (other is IMapEmpty || (other is IMapConst && (other as IMapConst)._map.isEmpty)) &&
    (config == other.config);