Commits

Meikel Brandmeyer committed 904e8d8

Extend ASeq via proxy

Comments (0)

Files changed (1)

src/main/clojure/de/kotka/lazymap.clj

     clojure.lang.IMapEntry
     clojure.lang.IPersistentMap
     clojure.lang.IPersistentVector
+    clojure.lang.ASeq
     clojure.lang.ISeq
     clojure.lang.Seqable
     clojure.lang.SeqIterator))
   (val           [_] (force v))
   (getValue      [_] (force v))
   Object
-  (toString      [_] (str \[ k \space (force v) \])))
+  (toString      [_] (str \[ (pr-str k) \space (pr-str (force v)) \])))
 
 (defmethod print-method LazyMapEntry
   [this #^java.io.Writer w]
   ([inner-seq]
    (create-lazy-map-seq inner-seq nil))
   ([inner-seq metadata]
-   (reify
-     ISeq
-     (first
-       [this]
+   (proxy [ASeq] [metadata]
+     ; ISeq
+     (first []
        (let [first-val (first inner-seq)]
          (LazyMapEntry. (key first-val) (val first-val))))
-     (next
-       [this]
+     (next []
        (when-let [inner-rest (next inner-seq)]
          (create-lazy-map-seq inner-rest metadata)))
-     (more  [this]   (lazy-seq (.next this)))
-     (cons  [this o] (create-lazy-map-seq (cons o inner-seq) metadata))
-     ; IPersistentCollection
-     (count [this]   (count inner-seq))
-     (empty [this]   ())
-     (seq   [this]   this))))
+     (more [] (lazy-seq (next this))))))
 
 (declare create-lazy-map)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.