PersistentHashSet.fromArray
function | since v0.0-1443 | Edit |
(PersistentHashSet.fromArray items no-clone)
(set! (.-fromArray PersistentHashSet)
(fn [items ^boolean no-clone]
(let [len (alength items)]
(if (<= len (.-HASHMAP-THRESHOLD PersistentArrayMap))
(let [arr (if no-clone items (aclone items))]
(loop [i 0
out (transient (.-EMPTY PersistentArrayMap))]
(if (< i len)
(recur (inc i) (-assoc! out (aget items i) nil))
(PersistentHashSet. nil (-persistent! out) nil))))
(loop [i 0
out (transient (.-EMPTY PersistentHashSet))]
(if (< i len)
(recur (inc i) (-conj! out (aget items i)))
(-persistent! out)))))))