Esempio n. 1
0
        public virtual OrderedSet <T> prepend(T item)
        {
            var result = new OrderedSet <T>();

            result.add(item);
            foreach (T i in this)
            {
                result.add(i);
            }

            return(result);
        }
Esempio n. 2
0
        public OrderedSet <T> including(T element)
        {
            var copy = new OrderedSet <T>(this);

            copy.add(element);
            return(copy);
        }
Esempio n. 3
0
        public OrderedSet <T> union(OrderedSet <T> other)
        {
            var union = new OrderedSet <T>();

            foreach (T element in this)
            {
                union.add(element);
            }

            foreach (T element in other)
            {
                union.add(element);
            }


            return(union);
        }
        public virtual OrderedSet <T> asOrderedSet()
        {
            var set = new OrderedSet <T>();

            foreach (T element in this)
            {
                set.add(element);
            }
            return(set);
        }
Esempio n. 5
0
        public OrderedSet <T> select(Func <T, bool> lambda)
        {
            var filter = this.Where(lambda);
            var result = new OrderedSet <T>();

            foreach (T element in filter)
            {
                result.add(element);
            }
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// http://download.eclipse.org/ocl/doc/6.0.0/ocl.pdf
        /// The OrderedSet consisting of objects, followed by all elements in self.
        ///
        /// OrderedSet{1,2,3}->prependAll(OrderedSet{2,3}) Results 2, 3, 1
        /// </summary>
        public OrderedSet <T> prependAll(Collection <T> collection)
        {
            var result = new OrderedSet <T>(collection);

            foreach (T item in this)
            {
                result.add(item);
            }

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// http://download.eclipse.org/ocl/doc/6.0.0/ocl.pdf
        /// The OrderedSet containing all elements of self and objects.
        /// </summary>
        public OrderedSet <T> includingAll(Collection <T> collection)
        {
            var result = new OrderedSet <T>(this);

            foreach (T item in collection)
            {
                result.add(item);
            }

            return(result);
        }
Esempio n. 8
0
        public virtual OrderedSet <T> append(T item)
        {
            var copy = new OrderedSet <T>(this);

            if (this.Contains(item))
            {
                copy.remove(item);
            }

            copy.add(item);
            return(copy);
        }
Esempio n. 9
0
        public OrderedSet <T2> flatten <T2>()
        {
            var result = new OrderedSet <T2>();

            foreach (object element in this)
            {
                if (element is OrderedSet <T2> )
                {
                    var subcollection = (OrderedSet <T2>)element;
                    foreach (T2 e in subcollection.flatten <T2>().asSet())
                    {
                        result.add(e);
                    }
                }
                else if (element is T2)
                {
                    var e = (T2)element;
                    result.add(e);
                }
            }

            return(result);
        }
Esempio n. 10
0
        public virtual OrderedSet <T> intersection(Set <T> other)
        {
            var result = new OrderedSet <T>();


            foreach (T item in this)
            {
                if (other.Contains(item))
                {
                    result.add(item);
                }
            }
            return(result);
        }
Esempio n. 11
0
        //http://download.eclipse.org/ocl/doc/6.0.0/ocl.pdf
        public OrderedSet <T> excludingAll(Collection <T> collection)
        {
            var result = new OrderedSet <T>();

            foreach (T item in this)
            {
                if (!collection.Contains(item))
                {
                    result.add(item);
                }
            }

            return(result);
        }
Esempio n. 12
0
        public OrderedSet <T2> collect <T2>(Func <T, T2> lambda)
        {
            var result = new OrderedSet <T2>();

            foreach (T element in this)
            {
                var item = lambda(element);
                if (item != null)
                {
                    result.add(item);
                }
            }

            return(result);
        }
Esempio n. 13
0
        public OrderedSet <T> reject(Func <T, bool> lambda)
        {
            var remove = this.Where(lambda);


            var result = new OrderedSet <T>();

            foreach (T element in this)
            {
                if (!remove.Contains(element))
                {
                    result.add(element);
                }
            }

            return(result);
        }
Esempio n. 14
0
        public OrderedSet <T2> collect <T2>(Func <T, Collection <T2> > lambda)
        {
            var result = new OrderedSet <T2>();

            foreach (T element in this)
            {
                var e = lambda(element);


                foreach (T2 ee in e)
                {
                    result.add(ee);
                }
            }

            return(result);
        }