same method

  1. @override
bool same(
  1. ISet<T>? other
)
override

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

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

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

Implementation

@override
bool same(ISet<T>? other) =>
    (other != null) &&
    (other is ISetEmpty || (other is ISetConst && (other as ISetConst)._set.isEmpty)) &&
    (config == other.config);