示例#1
0
文件: SET.cs 项目: Vespertan/everest
        /// <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);
        }
示例#2
0
文件: SET.cs 项目: Vespertan/everest
        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);
        }
示例#3
0
文件: SET.cs 项目: Vespertan/everest
        /// <summary>
        /// Parse a SET of T from the string <paramref name="s"/>
        /// </summary>
        /// <param name="s">The string to parse</param>
        /// <returns>The parsed set</returns>
        internal static SET <T> FromString(string s)
        {
            string[] values = s.Split(' ');
            SET <T>  retVal = new SET <T>((Comparison <T>)((a, b) => a.Equals(b) ? 0 : -1));

            foreach (string value in values)
            {
                retVal.Add((T)Util.FromWireFormat(value, typeof(T)));
            }
            return(retVal);
        }
示例#4
0
文件: SET.cs 项目: Vespertan/everest
        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);
        }
示例#5
0
文件: SET.cs 项目: Vespertan/everest
        /// <summary>
        /// Return a new DSET with all the contents of this DSET except the element specified
        /// </summary>
        public SET <T> Except(T element)
        {
            SET <T> retVal = new SET <T>();

            foreach (T item in this)
            {
                if (Comparator(item, element) != 0)
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
示例#6
0
文件: SET.cs 项目: Vespertan/everest
        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);
        }
示例#7
0
        /// <summary>
        /// Creates a set from a bound IVL
        /// </summary>
        /// <remarks>This function will call <see cref="F:FillInDetails"/> prior to construction of the set as it
        /// needs to ensure that low and high bounds are known</remarks>
        /// <exception cref="T:System.InvalidOperationException">When <typeparamref name="T"/> does not implement <see cref="T:MARC.Everest.DataTypes.Interfaces.IOrderedDataType{T}"/></exception>
        public SET <T> ToSet()
        {
            var lh = this.ToBoundIVL();

            if (lh.Low is IOrderedDataType <T> && lh.Low is IComparable <T> )
            {
                SET <T> retVal  = new SET <T>(10);
                var     current = lh.Low as IOrderedDataType <T>;
                while ((current as IComparable <T>).CompareTo(lh.High) <= (lh.HighClosed == true ? 0 : -1))
                {
                    retVal.Add((T)current);
                    current = current.NextValue() as IOrderedDataType <T>;
                }
                return(retVal);
            }
            else
            {
                throw new InvalidOperationException(String.Format(EverestFrameworkContext.CurrentCulture, "Cannot enumerate '{0}' to construct the resultant set", typeof(T).FullName));
            }
        }