Пример #1
0
        public bool IsSubset(GenericSet <T> other)
        {
            if (other.IsNull())
            {
                throw new ArgumentNullException("other");
            }

            if (this.Size > other.Size)
            {
                return(false);
            }
            return(data.Keys.All(item => other.Contains(item)));
        }
Пример #2
0
        public GenericSet <T> Difference(GenericSet <T> other)
        {
            if (other.IsNull())
            {
                throw new ArgumentNullException("other");
            }

            GenericSet <T> newSet = new GenericSet <T>();

            foreach (T item in data.Keys)
            {
                if (!other.Contains(item))
                {
                    newSet.Add(item);
                }
            }

            return(newSet);
        }
Пример #3
0
        public GenericSet <T> Intersection(GenericSet <T> other)
        {
            GenericSet <T> newSet = new GenericSet <T>();

            if (other.IsNull())
            {
                return(null);
            }

            foreach (T key in data.Keys)
            {
                if (other.Contains(key))
                {
                    newSet.Add(key);
                }
            }

            return(newSet);
        }