Example #1
0
        /// <summary>
        /// Returns a new set that contains the new elements and the old elements.
        /// </summary>
        public OrderedSet <T> Union(IEnumerable <T> new_elems)
        {
            var set = new OrderedSet <T>(this, count);

            set.AddRange(new_elems);
            return(set);
        }
Example #2
0
        public int CompareTo(object obj)
        {
            OrderedSet <T> os = obj as OrderedSet <T>;

            if (obj == null)
            {
                return(1);
            }
            if (count < os.count)
            {
                return(-1);
            }
            else if (count > os.count)
            {
                return(1);
            }
            else
            {
                var list1 = elements;
                var list2 = os.elements;
                while (list1 != null)
                {
                    int k = list1.First.CompareTo(list2.First);
                    if (k != 0)
                    {
                        return(k);
                    }
                    list1 = list1.Rest;
                    list2 = list2.Rest;
                }
                return(0);
            }
        }
Example #3
0
        /// <summary>
        /// Returns a new set that contains the new elements and the old elements.
        /// </summary>
        public OrderedSet <T> Union(params T[] new_elems)
        {
            var set = new OrderedSet <T>(this, count);

            set.AddRange(new_elems);
            return(set);
        }