Inheritance: APersistentSet, IObj, IEditableCollection
        public static PersistentHashSet create(ISeq items)
        {
            PersistentHashSet ret = EMPTY;

            for (; items != null; items = items.next())
            {
                ret = (PersistentHashSet)ret.cons(items.first());
            }
            return(ret);
        }
        public static PersistentHashSet create(IList init)
        {
            PersistentHashSet ret = EMPTY;

            foreach (object obj in init)
            {
                ret = (PersistentHashSet)ret.cons(obj);
            }
            return(ret);
        }
        public static PersistentHashSet create(params object[] init)
        {
            PersistentHashSet ret = EMPTY;

            for (int i = 0; i < init.Length; ++i)
            {
                ret = (PersistentHashSet)ret.cons(init[i]);
            }
            return(ret);
        }
Beispiel #4
0
        /// <summary>
        /// Create a <see cref="PersistentHashSet">PersistentHashSet</see> initialized from an IList of items.
        /// </summary>
        /// <param name="init">An IList of items.</param>
        /// <returns>A <see cref="PersistentHashSet">PersistentHashSet</see>.</returns>
        /// <remarks>This is called just 'create' in the Java version.  CLR can't handle this overload when called on something that is
        /// both an IList and an ISeq, such as any ASeq.</remarks>
        public static PersistentHashSet create1(IList init)
        {
            // TODO: Look for other collection classes with an overload problem on create(IList) and create(ISeq).
            PersistentHashSet ret = EMPTY;

            foreach (object obj in init)
            {
                ret = (PersistentHashSet)ret.cons(obj);
            }
            return(ret);
        }
        public static PersistentHashSet createWithCheck(params object[] init)
        {
            PersistentHashSet ret = EMPTY;

            for (int i = 0; i < init.Length; i++)
            {
                ret = (PersistentHashSet)ret.cons(init[i]);
                if (ret.count() != i + 1)
                {
                    throw new ArgumentException("Duplicate key: " + init[i]);
                }
            }
            return(ret);
        }
        public static PersistentHashSet createWithCheck(ISeq items)
        {
            PersistentHashSet ret = EMPTY;

            for (int i = 0; items != null; items = items.next(), ++i)
            {
                ret = (PersistentHashSet)ret.cons(items.first());
                if (ret.count() != i + 1)
                {
                    throw new ArgumentException("Duplicate key: " + items.first());
                }
            }
            return(ret);
        }
        public static PersistentHashSet createWithCheck(IList init)
        {
            PersistentHashSet ret = EMPTY;
            int i = 0;

            foreach (Object key in init)
            {
                ret = (PersistentHashSet)ret.cons(key);
                if (ret.count() != i + 1)
                {
                    throw new ArgumentException("Duplicate key: " + key);
                }
                ++i;
            }
            return(ret);
        }
Beispiel #8
0
 protected override object Read(PushbackTextReader r, char leftbracket, object opts)
 {
     return(PersistentHashSet.createWithCheck(ReadDelimitedList('}', r, true, opts)));
 }
Beispiel #9
0
 protected override object Read(PushbackTextReader r, char leftbracket)
 {
     return(PersistentHashSet.create1(readDelimitedList('}', r, true)));
 }