/// <summary> /// Initializes a new instance of the <see cref="HashSetEx{T}.Enumerator"/> struct. /// </summary> /// <param name="hashSet">The <see cref="HashSetEx{T}"/> to be enumerated.</param> internal Enumerator(HashSetEx<T> hashSet) { _hashSet = hashSet; _index = 0; _version = hashSet._version; _current = default(T); }
HashSetEx<T> ToHashSetEx(IEnumerable<T> enumerable) { var hashSet = enumerable as HashSetEx<T>; if (hashSet == null || !_comparer.Equals(hashSet.Comparer)) hashSet = new HashSetEx<T>(enumerable, _comparer); return hashSet; }
bool CheckIsSupersetOf(HashSetEx<T> other) { foreach (var item in other) if (!Contains(item)) return false; return true; }
bool CheckIsSubsetOf(HashSetEx<T> other) { foreach (var item in this) if (!other.Contains(item)) return false; return true; }
public int GetHashCode(HashSetEx<T> hashSet) { if (hashSet == null) return 0; var comparer = EqualityComparer<T>.Default; int hash = 0; foreach (var item in hashSet) hash ^= comparer.GetHashCode(item); return hash; }
public bool Equals(HashSetEx<T> lhs, HashSetEx<T> rhs) { if (lhs == rhs) return true; if (lhs == null || rhs == null || lhs.Count != rhs.Count) return false; // The following check assumes that both HashSetEx<T> use the same IEqualityComparer<T>! foreach (var item in lhs) if (!rhs.Contains(item)) return false; return true; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> public void Dispose() { _hashSet = null; _current = default(T); }