clojure.lang.PersistentHashMap.create C# (CSharp) Метод

create() приватный Метод

private create ( IDictionary other ) : IPersistentMap
other IDictionary
Результат IPersistentMap
        public static IPersistentMap create(IDictionary other)
        {
            ITransientMap ret = (ITransientMap)EMPTY.asTransient();
            foreach (DictionaryEntry e in other)
                ret = ret.assoc(e.Key, e.Value);
            return ret.persistent();
        }

Same methods

PersistentHashMap::create ( ) : PersistentHashMap
PersistentHashMap::create ( IPersistentMap meta ) : PersistentHashMap
PersistentHashMap::create ( ISeq items ) : PersistentHashMap

Usage Example

Пример #1
0
        /// <summary>
        /// Create a <see cref="PersistentArrayMap">PersistentArrayMap</see> (if small enough, else create a <see cref="PersistentHashMap">PersistentHashMap</see>.
        /// </summary>
        /// <param name="other">The BCL map to initialize from</param>
        /// <returns>A new persistent map.</returns>
        public static IPersistentMap create(IDictionary other)
        {
            // Java version has this.  Seems wasteful.
            //IPersistentMap ret = EMPTY;
            //foreach (DictionaryEntry e in other)
            //{
            //    ret = ret.assoc(e.Key, e.Value);
            //}
            //return ret;
            if (other.Count > HASHTABLE_THRESHOLD / 2)
            {
                return(PersistentHashMap.create(other));
            }

            object[] array = new object[other.Count * 2];
            int      i     = 0;

            foreach (DictionaryEntry e in other)
            {
                array[2 * i]     = e.Key;
                array[2 * i + 1] = e.Value;
                i++;
            }
            return(new PersistentArrayMap(array));
        }
All Usage Examples Of clojure.lang.PersistentHashMap::create