Exemplo n.º 1
0
 public void SymmetricExceptWith(IEnumerable <T> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     if (this.m_count == 0)
     {
         this.UnionWith(other);
     }
     else if (other == this)
     {
         this.Clear();
     }
     else
     {
         HashSet <T> set = other as HashSet <T>;
         if ((set != null) && HashSet <T> .AreEqualityComparersEqual((HashSet <T>) this, set))
         {
             this.SymmetricExceptWithUniqueHashSet(set);
         }
         else
         {
             this.SymmetricExceptWithEnumerable(other);
         }
     }
 }
Exemplo n.º 2
0
        public bool SetEquals(IEnumerable <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }
            HashSet <T> set = other as HashSet <T>;

            if ((set != null) && HashSet <T> .AreEqualityComparersEqual((HashSet <T>) this, set))
            {
                if (this.m_count != set.Count)
                {
                    return(false);
                }
                return(this.ContainsAllElements(set));
            }
            ICollection <T> is2 = other as ICollection <T>;

            if (((is2 != null) && (this.m_count == 0)) && (is2.Count > 0))
            {
                return(false);
            }
            ElementCount count = this.CheckUniqueAndUnfoundElements(other, true);

            return((count.uniqueCount == this.m_count) && (count.unfoundCount == 0));
        }
Exemplo n.º 3
0
        public bool IsProperSubsetOf(IEnumerable <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }
            ICollection <T> is2 = other as ICollection <T>;

            if (is2 != null)
            {
                if (this.m_count == 0)
                {
                    return(is2.Count > 0);
                }
                HashSet <T> set = other as HashSet <T>;
                if ((set != null) && HashSet <T> .AreEqualityComparersEqual((HashSet <T>) this, set))
                {
                    if (this.m_count >= set.Count)
                    {
                        return(false);
                    }
                    return(this.IsSubsetOfHashSetWithSameEC(set));
                }
            }
            ElementCount count = this.CheckUniqueAndUnfoundElements(other, false);

            return((count.uniqueCount == this.m_count) && (count.unfoundCount > 0));
        }
Exemplo n.º 4
0
 public void IntersectWith(IEnumerable <T> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     if (this.m_count != 0)
     {
         ICollection <T> is2 = other as ICollection <T>;
         if (is2 != null)
         {
             if (is2.Count == 0)
             {
                 this.Clear();
                 return;
             }
             HashSet <T> set = other as HashSet <T>;
             if ((set != null) && HashSet <T> .AreEqualityComparersEqual((HashSet <T>) this, set))
             {
                 this.IntersectWithHashSetWithSameEC(set);
                 return;
             }
         }
         this.IntersectWithEnumerable(other);
     }
 }
Exemplo n.º 5
0
 internal static bool HashSetEquals(HashSet <T> set1, HashSet <T> set2, IEqualityComparer <T> comparer)
 {
     if (set1 == null)
     {
         return(set2 == null);
     }
     if (set2 == null)
     {
         return(false);
     }
     if (HashSet <T> .AreEqualityComparersEqual(set1, set2))
     {
         if (set1.Count != set2.Count)
         {
             return(false);
         }
         foreach (T local in set2)
         {
             if (!set1.Contains(local))
             {
                 return(false);
             }
         }
         return(true);
     }
     foreach (T local2 in set2)
     {
         bool flag = false;
         foreach (T local3 in set1)
         {
             if (comparer.Equals(local2, local3))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
        public bool IsSupersetOf(IEnumerable <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }
            ICollection <T> is2 = other as ICollection <T>;

            if (is2 != null)
            {
                if (is2.Count == 0)
                {
                    return(true);
                }
                HashSet <T> set = other as HashSet <T>;
                if (((set != null) && HashSet <T> .AreEqualityComparersEqual((HashSet <T>) this, set)) && (set.Count > this.m_count))
                {
                    return(false);
                }
            }
            return(this.ContainsAllElements(other));
        }