Skip to content

Commit 5ad974d

Browse files
committed
Vector IIterable impl
1 parent 429d7ca commit 5ad974d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12274,6 +12274,15 @@ reduces them without incurring seq initialization"
1227412274

1227512275
;;; Vector
1227612276

12277+
(deftype VectorIterator [arr ^:mutable i]
12278+
Object
12279+
(hasNext [_]
12280+
(< i (alength arr)))
12281+
(next [_]
12282+
(let [x (aget arr i)]
12283+
(set! i (inc i))
12284+
x)))
12285+
1227712286
(deftype Vector [meta array ^:mutable __hash]
1227812287
Object
1227912288
(toString [coll]
@@ -12438,6 +12447,10 @@ reduces them without incurring seq initialization"
1243812447
(-persistent! [coll]
1243912448
coll)
1244012449

12450+
IIterable
12451+
(-iterator [coll]
12452+
(VectorIterator. array 0))
12453+
1244112454
IPrintWithWriter
1244212455
(-pr-writer [coll writer opts] (pr-sequential-writer writer pr-writer "[" " " "]" opts coll)))
1244312456

0 commit comments

Comments
 (0)