Example #1
0
        /// <summary>
        /// Makes so that the set contains only the elements that are also in this collection
        /// </summary>
        public void IntersectWith(IEnumerable <T> collection)
        {
            var intersectSet = new GenericSet <T>();

            foreach (var item in collection)
            {
                if (Contains(item))
                {
                    intersectSet.Add(item);
                }
            }

            this.head  = intersectSet.head;
            this.Count = intersectSet.Count;
            intersectSet.Clear();
        }
Example #2
0
        /// <summary>
        /// Checks if the set is a proper subset of given collection
        /// </summary>
        public bool IsProperSubsetOf(IEnumerable <T> collection)
        {
            var newSet = new GenericSet <T>();

            foreach (var item in collection)
            {
                newSet.Add(item);
            }

            foreach (var element in this)
            {
                if (!newSet.Contains(element))
                {
                    return(false);
                }
            }

            return(newSet.Count > Count);
        }