|
1 | 1 | # Tiara
|
2 | 2 | A small data structure library.
|
3 | 3 |
|
4 |
| -deps.edn |
| 4 | +### deps.edn |
5 | 5 |
|
6 | 6 | Add the following dependency to the :deps map in deps.edn:
|
7 | 7 |
|
8 |
| -io.github.quoll/tiara {:git/tag "v0.0.1" :git/sha ""} |
| 8 | +```clojure |
| 9 | +io.github.quoll/tiara {:git/tag "v0.0.1" :git/sha "52844a7"} |
| 10 | +``` |
| 11 | + |
| 12 | +## Usage |
| 13 | +At this point, Tiara only includes an ordered map. This has the same O(1) access characteristics as a hashmap, but maintains insertion order. |
| 14 | + |
| 15 | +Ordered Maps behave the same as other maps, but are only created using the `ordered-map` function. |
| 16 | + |
| 17 | +```clojure |
| 18 | +(require '[tiara.data :refer [ordered-map]]) |
| 19 | + |
| 20 | +(def m (ordered-map :a 1 :b 2 :c 3 :d 4 :e 5)) |
| 21 | +(def h (hash-map :a 1 :b 2 :c 3 :d 4 :e 5)) |
| 22 | + |
| 23 | +(= h m) ;; returns true |
| 24 | + |
| 25 | +(seq m) ;; => ([:a 1] [:b 2] [:c 3] [:d 4] [:e 5]) |
| 26 | + |
| 27 | +(assoc m :f 6) ;; => {:a 1, :b 2, :c 3, :d 4, :e 5, :f 6} |
| 28 | + ;; but existing keys do not change location: |
| 29 | +(assoc m :c 7) ;; => {:a 1, :b 2, :c 7, :d 4, :e 5} |
| 30 | + ;; to append, then remove first: |
| 31 | +(assoc (dissoc m :c) :c 7) ;; => {:a 1, :b 2, :d 4, :e 5, :c 7} |
| 32 | +``` |
| 33 | +## TODO |
| 34 | +- Hashmaps |
| 35 | +- Remove the first underlying hashmap |
| 36 | + |
| 37 | +## License |
| 38 | + |
| 39 | +Copyright © 2023 Paula Gearon |
| 40 | + |
| 41 | +_EPLv1.0 is just the default for projects generated by `deps-new`: you are not_ |
| 42 | +_required to open source this project, nor are you required to use EPLv1.0!_ |
| 43 | +_Feel free to remove or change the `LICENSE` file and remove or update this_ |
| 44 | +_section of the `README.md` file!_ |
| 45 | + |
| 46 | +Distributed under the Eclipse Public License version 2.0. |
0 commit comments