IndexedSeq
(IndexedSeq. arr i meta)
(deftype IndexedSeq [arr i meta]
Object
(toString [coll]
(pr-str* coll))
(equiv [this other]
(-equiv this other))
(indexOf [coll x]
(-indexOf coll x 0))
(indexOf [coll x start]
(-indexOf coll x start))
(lastIndexOf [coll x]
(-lastIndexOf coll x (count coll)))
(lastIndexOf [coll x start]
(-lastIndexOf coll x start))
ICloneable
(-clone [_] (IndexedSeq. arr i meta))
ISeqable
(-seq [this]
(when (< i (alength arr))
this))
IMeta
(-meta [coll] meta)
IWithMeta
(-with-meta [coll new-meta]
(if (identical? new-meta meta)
coll
(IndexedSeq. arr i new-meta)))
ASeq
ISeq
(-first [_] (aget arr i))
(-rest [_] (if (< (inc i) (alength arr))
(IndexedSeq. arr (inc i) nil)
(list)))
INext
(-next [_] (if (< (inc i) (alength arr))
(IndexedSeq. arr (inc i) nil)
nil))
IDrop
(-drop [coll n]
(if (pos? n)
(if (< (+ i n) (alength arr))
(IndexedSeq. arr (+ i n) nil)
nil)
coll))
ICounted
(-count [_]
(max 0 (- (alength arr) i)))
IIndexed
(-nth [coll n]
(let [i (+ n i)]
(if (and (<= 0 i) (< i (alength arr)))
(aget arr i)
(throw (js/Error. "Index out of bounds")))))
(-nth [coll n not-found]
(let [i (+ n i)]
(if (and (<= 0 i) (< i (alength arr)))
(aget arr i)
not-found)))
ISequential
IEquiv
(-equiv [coll other] (equiv-sequential coll other))
IIterable
(-iterator [coll]
(IndexedSeqIterator. arr i))
ICollection
(-conj [coll o] (cons o coll))
IEmptyableCollection
(-empty [coll] (.-EMPTY List))
IReduce
(-reduce [coll f]
(array-reduce arr f (aget arr i) (inc i)))
(-reduce [coll f start]
(array-reduce arr f start i))
IHash
(-hash [coll] (hash-ordered-coll coll))
IReversible
(-rseq [coll]
(let [c (-count coll)]
(if (pos? c)
(RSeq. coll (dec c) nil)))))