   (search [this k]))
 
 
-(deftype RangeMap [kind ^clojure.lang.IPersistentMap m]
+(deftype RangeMap [kind ^clojure.lang.IPersistentMap m leftfn rightfn]
 
   clojure.lang.IPersistentMap
 
   (assoc [this k v]
-    (->RangeMap kind (.assoc m k v)))
+    (->RangeMap kind (.assoc m k v) leftfn rightfn))
 
   (assocEx [this k v]
-    (.assocEx m k v)
-    this)
+    (->RangeMap kind (.assocEx m k v) leftfn rightfn))
 
 
   clojure.lang.ILookup

(defn range-map [kind & kvs]
  {:pre [(or (= kind :find-ceiling)
             (= kind :find-floor))]}
  (->RangeMap kind (apply sorted-map kvs)))


(defrecord B+Tree [b slots])


  (valAt [this k not-found]
    (let [idx (loop [ks     (keys m)
                     n      (count ks)
                     lastki nil]
                #_(println "LOOP1" lastki ks)
                (if (not-empty ks)
                  (let [i   (int (/ n 2))
                        ki  (get (vec ks) i)
                        cmp (compare ki k)]
                    #_(println "LOOP2" n i ki cmp)
                    (cond
                      (> cmp 0) (recur (take i ks)       i         (leftfn lastki ki))   ;; traverse left
                      (< cmp 0) (recur (drop (inc i) ks) (- n i 1) (rightfn lastki ki))  ;; traverse right
                      (= cmp 0) ki))
                  lastki))]
      (get m idx))))
