public static int GetHashCode <T>(HashSetValue <T> value) { ImmutableHashSet <T> underlyingSet = value.UnderlyingSet; int dataHashCode = 0; foreach (T element in underlyingSet) { // XOR, because the ordering must not matter. dataHashCode ^= EqualityComparer <T> .Default.GetHashCode(element); } return(HashCode.Seed .HashWith(underlyingSet.Count) .HashWith(dataHashCode)); }
public static bool Equals <T>(HashSetValue <T> first, HashSetValue <T> second) => first.SetEquals(second);