using System; using System.Collections; using System.Collections.Generic; namespace Unity.VisualScripting { public class NonNullableHashSet : ISet { public NonNullableHashSet() { set = new HashSet(); } public NonNullableHashSet(IEqualityComparer comparer) { set = new HashSet(comparer); } public NonNullableHashSet(IEnumerable collection) { set = new HashSet(collection); } public NonNullableHashSet(IEnumerable collection, IEqualityComparer comparer) { set = new HashSet(collection, comparer); } private readonly HashSet set; public int Count => set.Count; public bool IsReadOnly => false; public bool Add(T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return set.Add(item); } public void Clear() { set.Clear(); } public bool Contains(T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return set.Contains(item); } public void CopyTo(T[] array, int arrayIndex) { set.CopyTo(array, arrayIndex); } public void ExceptWith(IEnumerable other) { set.ExceptWith(other); } public IEnumerator GetEnumerator() { return set.GetEnumerator(); } public void IntersectWith(IEnumerable other) { set.IntersectWith(other); } public bool IsProperSubsetOf(IEnumerable other) { return set.IsProperSubsetOf(other); } public bool IsProperSupersetOf(IEnumerable other) { return set.IsProperSupersetOf(other); } public bool IsSubsetOf(IEnumerable other) { return set.IsSubsetOf(other); } public bool IsSupersetOf(IEnumerable other) { return set.IsSupersetOf(other); } public bool Overlaps(IEnumerable other) { return set.Overlaps(other); } public bool Remove(T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } return set.Remove(item); } public bool SetEquals(IEnumerable other) { return set.SetEquals(other); } public void SymmetricExceptWith(IEnumerable other) { set.SymmetricExceptWith(other); } public void UnionWith(IEnumerable other) { set.UnionWith(other); } void ICollection.Add(T item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } ((ICollection)set).Add(item); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)set).GetEnumerator(); } } }