Skip to content

Commit

Permalink
Use .iterator to implement the KeyValueIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
DanBurton committed Mar 9, 2016
1 parent be16cb5 commit d3b78e3
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/samza_config/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,11 @@
(.delete this k)))

(all [this]
(let [index (atom -1)
current-store (vec @store)]
(let [iterator (.iterator (map (fn [[k v]] (Entry. k v)) @store))]
(reify
java.util.Iterator
(hasNext [thiz]
(< (inc @index) (count current-store)))

(next [thiz]
(swap! index inc)
(let [[k v] (nth current-store @index)]
(Entry. k v)))

(remove [thiz]
(let [[k _] (nth current-store @index)]
(.delete this k)))

KeyValueIterator
(close [thiz]
(.close this)))))

(close [this]
nil)
(hasNext [this] (.hasNext iterator))
(next [this] (.next iterator)))))

(range [this from to]
(filter (fn [[k v]]
Expand Down

0 comments on commit d3b78e3

Please sign in to comment.