|
1 | 1 |
|
2 | 2 | {} (:package |bisection-key)
|
3 |
| - :configs $ {} (:init-fn |bisection-key.main/main!) (:reload-fn |bisection-key.main/reload!) (:version |0.0.15) |
| 3 | + :configs $ {} (:init-fn |bisection-key.main/main!) (:reload-fn |bisection-key.main/reload!) (:version |0.0.16) |
4 | 4 | :modules $ []
|
5 | 5 | :entries $ {}
|
6 | 6 | :test $ {} (:init-fn |bisection-key.test/run-tests) (:port 6001) (:reload-fn |bisection-key.test/run-tests)
|
|
333 | 333 | = (assoc v "\"aT" 4) (assoc-before-nth v 1 4)
|
334 | 334 | testing "\"set value after nth" $ is
|
335 | 335 | = (assoc v "\"bT" 4) (assoc-after-nth v 1 4)
|
| 336 | + testing "\"find key index a" $ is |
| 337 | + = 0 $ key-index-of v "\"a" |
| 338 | + testing "\"find key index c" $ is |
| 339 | + = 2 $ key-index-of v "\"c" |
| 340 | + testing "\"find key index missing" $ is |
| 341 | + = nil $ key-index-of v "\"d" |
336 | 342 | |test-prepend $ %{} :CodeEntry (:doc |)
|
337 | 343 | :code $ quote
|
338 | 344 | deftest test-prepend
|
|
355 | 361 | :ns $ %{} :CodeEntry (:doc |)
|
356 | 362 | :code $ quote
|
357 | 363 | ns bisection-key.test $ :require
|
358 |
| - [] calcit-test.core :refer $ [] deftest is testing run-tests |
359 |
| - [] bisection-key.core :refer $ [] max-id min-id mid-id bisect |
360 |
| - [] bisection-key.util :refer $ [] key-before key-after assoc-before assoc-after key-prepend key-append assoc-prepend assoc-append get-min-key get-max-key key-nth val-nth assoc-nth assoc-before-nth assoc-after-nth |
| 364 | + calcit-test.core :refer $ deftest is testing run-tests |
| 365 | + bisection-key.core :refer $ max-id min-id mid-id bisect |
| 366 | + bisection-key.util :refer $ key-before key-after assoc-before assoc-after key-prepend key-append assoc-prepend assoc-append get-min-key get-max-key key-nth val-nth assoc-nth assoc-before-nth assoc-after-nth key-index-of |
361 | 367 | |bisection-key.util $ %{} :FileEntry
|
362 | 368 | :defs $ {}
|
363 | 369 | |assoc-after $ %{} :CodeEntry (:doc |)
|
|
455 | 461 | bisect
|
456 | 462 | if (= 0 position) min-id $ get existing-keys (dec position)
|
457 | 463 | , base-key
|
| 464 | + |key-index-of $ %{} :CodeEntry (:doc "|find index of `k`, returns `nil` if not found") |
| 465 | + :code $ quote |
| 466 | + defn key-index-of (x k) |
| 467 | + let |
| 468 | + ks $ sort |
| 469 | + &set:to-list $ keys x |
| 470 | + , &compare |
| 471 | + index-of ks k |
458 | 472 | |key-nth $ %{} :CodeEntry (:doc |)
|
459 | 473 | :code $ quote
|
460 | 474 | defn key-nth (x n)
|
|
0 commit comments