1using System.Collections;
2using System.Collections.Generic;
3using System.Runtime.Serialization;
10 [DataContract(Name =
"Set", Namespace = Constants.DataContractNamespace)]
11 public class Set<T> : ICollection<T>, IEnumerable<T>, IEnumerable, IReadOnlyCollection<T>, ISet<T>
16 public HashSet<T>
HashSet {
get;
private set; } =
new HashSet<T>();
21 [DataMember(Order = 1, Name =
"Values")]
36 public Set(IEnumerable<T> collection)
38 HashSet =
new HashSet<T>(collection);
45 public static implicit
operator Set<T>(HashSet<T>
set)
56 return System.Array.Empty<T>();
58 var array =
new T[
HashSet.Count];
70 void ICollection<T>.Add(T item)
72 ((ICollection<T>)
HashSet).Add(item);
88 public void CopyTo(T[] array,
int arrayIndex)
90 HashSet.CopyTo(array, arrayIndex);
102 return HashSet.GetEnumerator();
106 IEnumerator<T> IEnumerable<T>.GetEnumerator()
108 return HashSet.GetEnumerator();
120 return HashSet.IsProperSubsetOf(other);
126 return HashSet.IsProperSupersetOf(other);
132 return HashSet.IsSubsetOf(other);
138 return HashSet.IsSupersetOf(other);
144 return HashSet.Overlaps(other);
156 return HashSet.SetEquals(other);
162 HashSet.SymmetricExceptWith(other);
178 IEnumerator IEnumerable.GetEnumerator()
180 return ((IEnumerable)
HashSet).GetEnumerator();
A hash set that is data contract serializable.
bool SetEquals(IEnumerable< T > other)
void UnionWith(IEnumerable< T > other)
void IntersectWith(IEnumerable< T > other)
bool IsSupersetOf(IEnumerable< T > other)
Set(IEnumerable< T > collection)
Initializes a new hash set from a collection.
bool IsProperSubsetOf(IEnumerable< T > other)
bool IsSubsetOf(IEnumerable< T > other)
T[] GetArray()
Returns a new array of hash set entries.
HashSet< T > HashSet
The underlying hash set.
HashSet< T >.Enumerator GetEnumerator()
bool Overlaps(IEnumerable< T > other)
T[] Array
An array of hash set entries.
void CopyTo(T[] array, int arrayIndex)
void SymmetricExceptWith(IEnumerable< T > other)
Set()
Initializes a new hash set.
bool IsProperSupersetOf(IEnumerable< T > other)
void ExceptWith(IEnumerable< T > other)