Skip to content

Commit b1b09bb

Browse files
thomasmulvaneydnolen
authored and
dnolen
committed
CLJS-2137: Missing INext on some sequences
Added INext to ArrayNodeSeq, NodeSeq, PersistentQueueSeq and PersistentTreeMapSeq
1 parent d598fd9 commit b1b09bb

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/main/cljs/cljs/core.cljs

+25
Original file line numberDiff line numberDiff line change
@@ -5829,6 +5829,13 @@ reduces them without incurring seq initialization"
58295829
(-empty coll)
58305830
(PersistentQueueSeq. meta rear nil nil))))
58315831

5832+
INext
5833+
(-next [coll]
5834+
(if-let [f1 (next front)]
5835+
(PersistentQueueSeq. meta f1 rear nil)
5836+
(when (some? rear)
5837+
(PersistentQueueSeq. meta rear nil nil))))
5838+
58325839
ICollection
58335840
(-conj [coll o] (cons o coll))
58345841

@@ -7301,6 +7308,12 @@ reduces them without incurring seq initialization"
73017308
(create-inode-seq nodes i (next s)))]
73027309
(if-not (nil? ret) ret ())))
73037310

7311+
INext
7312+
(-next [coll]
7313+
(if (nil? s)
7314+
(create-inode-seq nodes (+ i 2) nil)
7315+
(create-inode-seq nodes i (next s))))
7316+
73047317
ISeqable
73057318
(-seq [this] this)
73067319

@@ -7367,6 +7380,10 @@ reduces them without incurring seq initialization"
73677380
(let [ret (create-array-node-seq nil nodes i (next s))]
73687381
(if-not (nil? ret) ret ())))
73697382

7383+
INext
7384+
(-next [coll]
7385+
(create-array-node-seq nil nodes i (next s)))
7386+
73707387
ISeqable
73717388
(-seq [this] this)
73727389

@@ -7724,6 +7741,14 @@ reduces them without incurring seq initialization"
77247741
(if-not (nil? next-stack)
77257742
(PersistentTreeMapSeq. nil next-stack ascending? (dec cnt) nil)
77267743
())))
7744+
INext
7745+
(-next [this]
7746+
(let [t (first stack)
7747+
next-stack (tree-map-seq-push (if ascending? (.-right t) (.-left t))
7748+
(next stack)
7749+
ascending?)]
7750+
(when-not (nil? next-stack)
7751+
(PersistentTreeMapSeq. nil next-stack ascending? (dec cnt) nil))))
77277752

77287753
ICounted
77297754
(-count [coll]

src/test/cljs/cljs/collections_test.cljs

+3-1
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,10 @@
678678
(is (= (find map nil) [nil :foo])))))
679679

680680
(deftype CustomVectorThing [v]
681+
;; Subvec expects its argument to implement IVector.
682+
;; Note, that this method is never actually called.
681683
IVector
682-
(-assoc-n [coll i val] (assoc-n v i val))
684+
(-assoc-n [coll i val] nil)
683685

684686
IIndexed
685687
(-nth [coll i] (nth v i))

0 commit comments

Comments
 (0)