| cs-llrb - Chez Scheme implementation of left-leaning red-black trees.
git clone https://benconnors.ca/git-repos/cs-llrb |
README.md (894B) - raw
1 # LLRB for Chez Scheme 2 A basic implementation of a left-leaning red-black tree for Chez Scheme. 3 4 ## Functions 5 ``` 6 (make-tree cmp) 7 ``` 8 Create a new tree using the comparison function `(cmp a b)`, which returns a negative number if `a < b`, zero if `a = b`, and a positive number if `a > b` (or vice-versa). 9 10 ``` 11 (tree-insert! t key value) 12 ``` 13 Insert `value` at `key` in tree `t`. This will replace an existing node or create a new one if the key doesn't exist. Returns `t`. 14 15 ``` 16 (tree-delete! t key) 17 ``` 18 Delete the value at `key` in tree `t`. Returns `#t` if `key` was present and `#f` otherwise. 19 20 ``` 21 (tree-search t key) 22 ``` 23 Search the tree `t` for `key` and return its value; if not found, raises `not-found`. 24 25 ``` 26 (tree-get t key not-found) 27 ``` 28 Search the tree `t` for `key` and return its value; if not found, returns `not-found`. 29 30 ``` 31 (tree-has? t key) 32 ``` 33 Check if the tree `t` has `key`.