                         left-vals (.-vals left-node)]
                     (if (> (alength left-keys) min-keys)
                       (do
+                        (prn "rotate-left")
                         (.unshift keys (.pop left-keys))
                         (.unshift vals (.pop left-vals))
                         (set! lower (aget keys 0))

(ns aurora.btree
  (:require-macros [aurora.macros :refer [apush lt lte gt gte]]))

;; NOTE iterators are not write-safe


     (js/console.log tree)
     (for [i (range 10)] (.seek (iterator tree) i))
     ))

  (let [tree (tree 1)]
    (.assoc! tree "foo")
    (.dissoc! tree "bar")
    (.valid! tree)
    tree)

  (let [tree (tree 1)]
    (.assoc! tree "foo")
    (.assoc! tree "bar")
    (.dissoc! tree "bar")
    #_(.valid! tree)
    tree)

  (do
    (def t (tree 1))
    (.assoc! t "a" 0)
    (.assoc! t 1 "b")
    (.assoc! t "c" 2)
    (.assoc! t 3 "d")
    (.assoc! t "e" 4)
    (.assoc! t 5 "f")
    (.assoc! t "g" 6)
    (.pretty-print t)
    (.dissoc! t "a")
    (.pretty-print t)
    (js/console.log t)
    (.valid! t)
    t)

  (let [tree (tree 1)]
    (dotimes [i 1000]
      (.assoc! tree (js/Math.sin i) (* 2 i)))
    (dotimes [i 1000]
      (print i)
      (.valid! tree)
      (.dissoc! tree (js/Math.sin i) (* 2 i)))
    #_(.valid! tree)
    (= (map #(.apply vector nil %) tree) (sort (for [i (range 1000)] [(js/Math.sin i) (* 2 i)]))))
  )
