mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 23:51:37 +02:00
Add intervaltree related code to experiments/bench environment script.
This commit is contained in:
parent
9d5ba9d731
commit
9c7fb455a6
1 changed files with 23 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
(ns bench.core
|
(ns bench.core
|
||||||
(:require [kdtree.core :as k]
|
(:require [kdtree.core :as k]
|
||||||
|
[intervaltree.core :as it]
|
||||||
[cljs.pprint :refer (pprint)]
|
[cljs.pprint :refer (pprint)]
|
||||||
[cljs.nodejs :as node]))
|
[cljs.nodejs :as node]))
|
||||||
|
|
||||||
|
@ -76,6 +77,25 @@
|
||||||
(pprint (js->clj (.nearest tree #js [1742 1420] 6)))
|
(pprint (js->clj (.nearest tree #js [1742 1420] 6)))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(defn test-interval
|
||||||
|
[]
|
||||||
|
(let [tree (doto (it/create)
|
||||||
|
(.add #js [1 5])
|
||||||
|
(.add #js [5 7])
|
||||||
|
(.add #js [-4 -1])
|
||||||
|
(.add #js [-10 -3])
|
||||||
|
(.add #js [-20 -10])
|
||||||
|
(.add #js [20 30])
|
||||||
|
(.add #js [3 9])
|
||||||
|
(.add #js [100 200])
|
||||||
|
(.add #js [1000 2000])
|
||||||
|
(.add #js [6 9])
|
||||||
|
)]
|
||||||
|
(js/console.dir tree #js {"depth" nil})
|
||||||
|
(js/console.log "contains", 4, (.contains tree 4))
|
||||||
|
(js/console.log "contains", 0, (.contains tree 0))
|
||||||
|
))
|
||||||
|
|
||||||
(defn main
|
(defn main
|
||||||
[& [type]]
|
[& [type]]
|
||||||
(cond
|
(cond
|
||||||
|
@ -88,6 +108,9 @@
|
||||||
(= type "test")
|
(= type "test")
|
||||||
(test-accuracity)
|
(test-accuracity)
|
||||||
|
|
||||||
|
(= type "interval")
|
||||||
|
(test-interval)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(println "not implemented")))
|
(println "not implemented")))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue