Commits

Anonymous committed 7cdc771

Derive LazyMap from c.l.APersistentMap (patch by Erik Söhnel)

Comments (0)

Files changed (1)

src/de/kotka/lazymap/LazyMap.clj

   (:gen-class
      :init         init
      :state        theMap
+     :extends      clojure.lang.APersistentMap
      :methods      [[lazyAssoc [Object Object] clojure.lang.IPersistentMap]]
-     :implements   [clojure.lang.IPersistentMap clojure.lang.IFn
-                    clojure.lang.IObj]
-     :constructors {[clojure.lang.IPersistentMap] []})
+     :constructors {[clojure.lang.IPersistentMap] []
+                    [clojure.lang.IPersistentMap clojure.lang.IPersistentMap]
+                    [clojure.lang.IPersistentMap]})
   (:import
      (clojure.lang SeqIterator IMapEntry IPersistentVector IObj)))
 
 (defn- -init
-  [theMap]
-  [[] theMap])
+  ([theMap]
+   [[] theMap])
+  ([theMap metaData]
+   [[metaData] theMap]))
 
 (defn- -lazyAssoc
   [#^de.kotka.lazymap.LazyMap this k v]
   (de.kotka.lazymap.LazyMap. (-> this .theMap (assoc k v))))
 
 ; IObj
-(defn- -meta
-  [#^de.kotka.lazymap.LazyMap this]
-  (-> this .theMap meta))
-
 (defn- -withMeta
   [#^de.kotka.lazymap.LazyMap this meta-data]
-  (de.kotka.lazymap.LazyMap. (-> this .theMap (with-meta meta-data))))
+  (de.kotka.lazymap.LazyMap. (.theMap this) meta-data))
 
 ; IPersistentMap
 (defn- -assoc
 (defn- -empty
   [#^de.kotka.lazymap.LazyMap this]
   (-> this .theMap empty de.kotka.lazymap.LazyMap.))
-
-; IFn
-(defn- -invoke
-  [#^de.kotka.lazymap.LazyMap this & ks]
-  (.valAt this (first ks)))
-
-(defn- -applyTo
-  [#^de.kotka.lazymap.LazyMap this ks]
-  (.valAt this (first ks)))