diff options
| author | 2025-01-16 23:16:32 -0500 | |
|---|---|---|
| committer | 2025-01-16 23:16:32 -0500 | |
| commit | 500be7d0c9d8ef212448eb20b6ebd22f38ee0189 (patch) | |
| tree | 28c8c83e3f455b1a9f60d77a3c504b3a00256b8f /doc | |
| parent | join2 (diff) | |
split and search
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/mcgoron.weight-balanced-trees.internal.scm | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/doc/mcgoron.weight-balanced-trees.internal.scm b/doc/mcgoron.weight-balanced-trees.internal.scm index 5812d72..176d18e 100644 --- a/doc/mcgoron.weight-balanced-trees.internal.scm +++ b/doc/mcgoron.weight-balanced-trees.internal.scm @@ -18,10 +18,7 @@ (desc "Returns the number of elements in this tree.")) ((name . "balanced?") (signature lambda ((wb-tree-node? x)) => boolean?) - (tags internal) - (desc "Recursively traverses `x` and checks if it is weight balanced. -This function is not called in normal code, but can be useful for -debugging.")) + (desc "Recursively traverses `x` and checks if it is weight balanced.")) ((name . "in-order-vector->node") (signature lambda ((vector? x)) => wb-tree-node?) (desc " @@ -45,4 +42,33 @@ elements of `x`.")) `right`. Returns a balanced tree containing all elements of `left` and `right` -with `data`.")))
\ No newline at end of file +with `data`.")) + ((name . "join2") + (signature lambda ((wb-tree-node? left) (wb-tree-node? right)) + => wb-tree-node?) + (desc " +* It is an error if any element in `left` is greater than or equal to any + element in `right`. + +Returns a new tree with the elements of `left` and `right`.")) + ((name . "split") + (signature lambda ((comparator? cmp) (wb-tree-node? tree) key) + => (values wb-tree-node? boolean? wb-tree-node?)) + " +* It is an error if any element of `tree` is not comparable by `cmp`. +* It is an error if `key` is not comparable by `cmp`. +* It is an error if `cmp` does not have an order. + +Returns two trees, one of all values to the left of `key`, and one with +all values to the right of `key`. The boolean is true if the key was +found and false otherwise.") + ((name . "search") + (signature case-lambda ((((wb-tree-node? tree) (comparator? cmp) key) *) + (((wb-tree-node? tree) (comparator? cmp) key (procedure? default)) *))) + (desc " +* It is an error if `cmp` does not order `key` and all elements in `tree`. +* It is an error if `default` is not a thunk. + +Searches `tree` for `key` using `cmp`. If a node contains data that compares equal +to `key`, return that data. Otherwise, tail call `default.` If `default` is not +supplied, the function returns `#f`.")))
\ No newline at end of file |
