                               inc))
 (def ^:const ^number path-mask (dec (bit-shift-left 1 level-shift)))
 (def ^:const ^number empty-path 0)
-(def ^:dynamic *cmp* compare)
+(def ^:dynamic *cmp*)
 
 (defn ^number path-get [^number path
                         ^number level]

      (-write writer "\n")
      (dump (aget (.-pointers node) i) writer (str "  " offset)))))

(extend-type BTSet
  IPrintWithWriter
  (-pr-writer [o writer _]
    (dump (.-root o) writer "")))

;; (def s0 (into (btset) (shuffle (range 10000))))
;; (reduce disj s0 (shuffle (range 9995)))

  ILookup 
  (-lookup [set k]
    (-lookup set k nil))
  (-lookup [_ k not-found]
    (binding [*cmp* comparator]
      (or (.lookup root k) not-found)))

  ISeqable
  (-seq [this]
    (btset-iter this))
  
  ICounted
  (-count [_] cnt)
 
  IFn
  (-invoke [coll k]
    (-lookup coll k))
  (-invoke [coll k not-found]
    (-lookup coll k not-found))
  
  IPrintWithWriter
  (-pr-writer [this writer opts]
    (pr-sequential-writer writer pr-writer "#{" " " "}" opts (seq this))))

(defn alter-btset [set root shift cnt]
  (BTSet. root shift cnt (.-comparator set) (.-meta set) nil))

(defn btset-by
  ([cmp] (BTSet. (LeafNode. (array)) 0 0 cmp nil 0))
  ([cmp & keys]
    (reduce -conj (btset-by cmp) keys)))

