示例#1
0
 /// <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);
 }
示例#2
0
    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;
    }
示例#3
0
    bool CheckIsSupersetOf(HashSetEx<T> other)
    {
      foreach (var item in other)
        if (!Contains(item))
          return false;

      return true;
    }
示例#4
0
    bool CheckIsSubsetOf(HashSetEx<T> other)
    {
      foreach (var item in this)
        if (!other.Contains(item))
          return false;

      return true;
    }
示例#5
0
      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;
      }
示例#6
0
      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;
      }
示例#7
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting 
 /// unmanaged resources.
 /// </summary>
 public void Dispose()
 {
   _hashSet = null;
   _current = default(T);
 }