Exemple #1
0
        /// <summary>
        /// Creates a new enum set, containing only the specified elements. There are
        /// six overloadings of the method. They accept from one to five elements
        /// respectively. The sixth one receives arbitrary number of elements, and
        /// runs slower than those only receive fixed number of elements.
        /// </summary>
        /// <typeparam name="E"></typeparam>
        /// <param name="e1"></param>
        /// <param name="e2"></param>
        /// <param name="e3"></param>
        /// <param name="e4"></param>
        /// <param name="e5"></param>
        /// <returns></returns>
        public static EnumSet <E> Of <E>(E e1, E e2, E e3, E e4, E e5)
        {
            EnumSet <E> set = Of <E>(e1, e2, e3, e4);

            set.Add(e5);
            return(set);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new enum set, containing only the specified elements. There are
        /// six overloadings of the method. They accept from one to five elements
        /// respectively. The sixth one receives arbitrary number of elements, and
        /// runs slower than those only receive fixed number of elements.
        /// </summary>
        /// <typeparam name="E"></typeparam>
        /// <param name="e1"></param>
        /// <param name="e2"></param>
        /// <param name="e3"></param>
        /// <returns></returns>
        public static EnumSet <E> Of <E>(E e1, E e2, E e3)
        {
            EnumSet <E> set = Of <E>(e1, e2);

            set.Add(e3);
            return(set);
        }
Exemple #3
0
        /// <summary>
        /// Creates a new enum set, containing only the specified elements. There are
        /// six overloadings of the method. They accept from one to five elements
        /// respectively. The sixth one receives arbitrary number of elements, and
        /// runs slower than those only receive fixed number of elements.
        /// </summary>
        /// <param name="e1"></param>
        /// <param name="e2"></param>
        /// <returns></returns>
        public static EnumSet <E> Of(E e1, E e2)
        {
            EnumSet <E> set = Of <E>(e1);

            set.Add(e2);
            return(set);
        }
Exemple #4
0
        /// <summary>
        /// Creates a new enum set, containing only the specified element. There are
        /// six overloadings of the method. They accept from one to five elements
        /// respectively. The sixth one receives arbitrary number of elements, and
        /// runs slower than those only receive fixed number of elements.
        /// </summary>
        /// <typeparam name="E"></typeparam>
        /// <param name="e"></param>
        /// <returns></returns>
        public static EnumSet <E> Of <E>(E e)
        {
            EnumSet <E> set = EnumSet <E> .NoneOf <E>(((object)e).GetType());

            set.Add(e);
            return(set);
        }
Exemple #5
0
        /// <summary>
        /// Creates a new enum set, containing only the specified elements. It
        /// receives arbitrary number of elements, and runs slower than those only
        /// receive fixed number of elements.
        /// </summary>
        /// <typeparam name="E"></typeparam>
        /// <param name="start"></param>
        /// <param name="others"></param>
        /// <returns></returns>
        public static EnumSet <E> Of <E>(E start, params E[] others)
        {
            EnumSet <E> set = Of <E>(start);

            foreach (E e in others)
            {
                set.Add(e);
            }
            return(set);
        }
Exemple #6
0
        /// <summary>
        /// Creates an enum set. The contained elements are the same as those
        /// contained in collection c. If c is an enum set, invoking this method is
        /// the same as invoking {@link #copyOf(EnumSet)}.
        /// </summary>
        /// <typeparam name="E"></typeparam>
        /// <param name="c"></param>
        /// <returns></returns>
        public static EnumSet <E> CopyOf <E>(ICollection <E> c)
        {
            if (c is EnumSet <E> )
            {
                return(CopyOf((EnumSet <E>)c));
            }
            if (0 == c.Count)
            {
                throw new Exception("IllegalArgumentException");
            }
            IEnumerator <E> iterator = c.GetEnumerator();

            iterator.MoveNext();
            E           element = iterator.Current;
            EnumSet <E> set     = EnumSet <E> .NoneOf <E>((Type)((object)element).GetType());

            set.Add(element);
            while (iterator.MoveNext())
            {
                set.Add(iterator.Current);
            }
            return(set);
        }