Finish integrating new BST implementation.
This commit is contained in:
parent
f3bcfcaa6a
commit
005c2c1cf1
3 changed files with 122 additions and 3 deletions
116
doc/d-utils.md
116
doc/d-utils.md
|
@ -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))
|
||||
|
||||
|
||||
|
|
|
@ -62,13 +62,14 @@ GENDOC-SOURCES=gendoc.scm duck-extract.import.scm \
|
|||
util-io.import.scm util-stdout.import.scm \
|
||||
util-parser.import.scm util-list.import.scm \
|
||||
util-proc.import.scm util-format.import.scm \
|
||||
util-tag.import.scm util-string.import.scm
|
||||
util-tag.import.scm util-string.import.scm \
|
||||
util-bst.import.scm
|
||||
|
||||
GENDOC-OBJS=gendoc.o duck-extract.o util-time.o util-csv.o util-io.o \
|
||||
progress.o testing.o util-proc.o util-git.o util-io.o \
|
||||
util-stdout.o util-parser.o util-list.o util-proc.o \
|
||||
util-format.o racket-kwargs.o util-dict-list.o util-tag.o \
|
||||
util-set-list.o duck.o util-string.o
|
||||
util-set-list.o duck.o util-string.o util-bst.o
|
||||
|
||||
.PHONY: imports
|
||||
imports: $(HACKERBASE-DEPS)
|
||||
|
@ -518,7 +519,8 @@ DUCK-EXTRACT-SOURCES=duck-extract.scm util-proc.import.scm
|
|||
duck-extract.o: duck-extract.import.scm
|
||||
duck-extract.import.scm: $(DUCK-EXTRACT-SOURCES)
|
||||
|
||||
UTIL-BST-SOURCES=util-bst.scm util-tag.import.scm testing.import.scm
|
||||
UTIL-BST-SOURCES=util-bst.scm util-tag.import.scm testing.import.scm \
|
||||
duck.import.scm
|
||||
|
||||
util-bst.o: util-bst.import.scm
|
||||
util-bst.import.scm: $(UTIL-BST-SOURCES)
|
||||
|
|
|
@ -32,4 +32,5 @@
|
|||
util-tag
|
||||
util-string
|
||||
util-mail
|
||||
util-bst
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue