Finish integrating new BST implementation.

This commit is contained in:
Dominik Pantůček 2023-07-07 10:50:31 +02:00
parent f3bcfcaa6a
commit 005c2c1cf1
3 changed files with 122 additions and 3 deletions

View file

@ -437,3 +437,119 @@ sent to the address stored within.
Sends email using mail(1) command. The arguments ```#:to``` and
```#:subject``` are mandatory. Argument ```#:from``` is optional.
## util-bst [module]
(import util-bst)
Binary Search Tree implementation
### make-bst [procedure]
(make-bst subtag
EQ?
<?)
Creates empty BST with given comparators
### (bst? subtag) [procedure]
((bst? v)
subtag)
Curried predicate for particular bst type.
### bst-empty? [procedure]
(bst-empty? bst)
Returns #t if given BST is empty.
### bst-ref [procedure]
(bst-ref bst
k
. vs)
Retrieves value associated with given key.
### bst-contains? [procedure]
(bst-contains? bst
k)
Predicate for key existence in BST.
### bst-set [procedure]
(bst-set bst
k
v)
Sets given key to given value and updates count if needed.
### bst-remove [procedure]
(bst-remove bst
k
. nos)
Removes given key from the BST.
### bst-keys [procedure]
(bst-keys bst)
Returns all the keys contained in given dictionary.
### bst-balance [procedure]
(bst-balance bst)
Unconditionally balances the BST.
### bst-find-pair [procedure]
(bst-find-pair bst
pred?)
Finds pair by predicate that accepts both key and value.
### bst-filter-pairs [procedure]
(bst-filter-pairs bst
pred?)
Returns a list of key-value pairs matching predicate.
### bst-map-list [procedure]
(bst-map-list bst
proc)
Returns arbitrary list created by mapping all elements.
### bst-map-bst [procedure]
(bst-map-bst bst
proc)
Returns a new dictionary with all values processed (keys are left intact).
### list->bst [procedure]
(list->bst lst
subtag
EQ?
<?)
Converts list of pairs into BST dictionary.
### bst-update [procedure]
(bst-update bst
k
proc
(v #f))