Пример #1
0
        public SET <T> Intersection(SET <T> otherset)
        {
            SET <T> retVal = new SET <T>(this.Comparator);

            foreach (T item in this)
            {
                if (otherset.Contains(item))
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Пример #2
0
        public SET <T> Except(SET <T> otherset)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                if (!otherset.Contains(item))
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Пример #3
0
        /// <summary>
        /// Create a union of this set and another set
        /// </summary>
        public SET <T> Union(T element)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                retVal.Add(item);
            }
            if (!retVal.Contains(element))
            {
                retVal.Add(element);
            }
            return(retVal);
        }
Пример #4
0
        public SET <T> Union(SET <T> otherset)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                retVal.Add(item);
            }
            foreach (T item in otherset)
            {
                if (!retVal.Contains(item))
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }