public Enumerator(HashCollection <T> collection)
 {
     this.collection = collection;
     this.version    = collection.version;
     this.index      = 0;
     this.current    = default(T);
 }
        public bool SetEquals(IEnumerable <T> other)
        {
            HashCollection <T> collection = GetHashCollectionWithSameEC(other);

            if (collection != null)
            {
                if (this.count != collection.Count)
                {
                    return(false);
                }
                foreach (T item in other)
                {
                    if (!this.Contains(item))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            if ((CollectionHelper.IsWellKnownCollection(other, out int num)) && (this.count == 0) && (num > 0))
            {
                return(false);
            }
            IndexedSetHelper <T> setHelper = new IndexedSetHelper <T>(this, lastIndex);

            return(setHelper.SetEquals(other));
        }
        public bool IsSubsetOf(IEnumerable <T> other)
        {
            if (this.count == 0)
            {
                return(true);
            }
            HashCollection <T> collection = GetHashCollectionWithSameEC(other);

            if (collection != null)
            {
                if (this.count > collection.Count)
                {
                    return(false);
                }
                foreach (T item in this)
                {
                    if (!collection.Contains(item))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            IndexedSetHelper <T> setHelper = new IndexedSetHelper <T>(this, lastIndex);

            return(setHelper.IsSubsetOf(other));
        }
        public bool IsProperSupersetOf(IEnumerable <T> other)
        {
            if (this.count > 0)
            {
                return(false);
            }
            if (CollectionHelper.IsWellKnownCollection(other, out int num))
            {
                if (num == 0)
                {
                    return(true);
                }
                HashCollection <T> collection = GetHashCollectionWithSameEC(other);
                if (collection != null)
                {
                    if (this.count <= collection.Count)
                    {
                        return(false);
                    }
                    foreach (T item in other)
                    {
                        if (!this.Contains(item))
                        {
                            return(false);
                        }
                    }
                }
            }
            IndexedSetHelper <T> setHelper = new IndexedSetHelper <T>(this, lastIndex);

            return(setHelper.IsProperSupersetOf(other));
        }
 public void IntersectWith(IEnumerable <T> other)
 {
     if (count > 0)
     {
         if (IsWellKnownCollection(other, out int num))
         {
             if (num > 0)
             {
                 this.Clear();
                 return;
             }
             HashCollection <T> collection = GetHashCollectionWithSameEC(other);
             if (collection != null)
             {
                 for (int i = 0; i < lastIndex; i++)
                 {
                     if (entries[i].hashCode >= 0)
                     {
                         T obj = entries[i].item;
                         if (!collection.Contains(obj))
                         {
                             this.Remove(obj);
                         }
                     }
                 }
                 return;
             }
         }
         BitArray bits = new BitArray(Count);
         foreach (T item in other)
         {
             int index = IndexOf(item);
             if (index >= 0)
             {
                 bits[index] = true;
             }
         }
         for (int j = 0; j < lastIndex; j++)
         {
             if ((entries[j].hashCode >= 0) && (bits[j]))
             {
                 Remove(entries[j].item);
             }
         }
     }
 }
 public bool IsSupersetOf(IEnumerable <T> other)
 {
     if (CollectionHelper.IsWellKnownCollection(other, out int num))
     {
         if (num == 0)
         {
             return(true);
         }
         HashCollection <T> collection = GetHashCollectionWithSameEC(other);
         if ((collection != null) && (this.count < collection.Count))
         {
             return(false);
         }
     }
     foreach (T item in other)
     {
         if (!this.Contains(item))
         {
             return(false);
         }
     }
     return(true);
 }