aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-01-16 19:40:06 -0500
committerGravatar Peter McGoron 2025-01-16 19:40:06 -0500
commit0d5d0f16c5b4c969e01a0ec27954b69a967c4970 (patch)
tree3a74a912396ed03b1ab3d74947dc394b0bea9355
parentsuccesfully test join (diff)
rename module to internal
-rw-r--r--README.md6
-rw-r--r--doc/mcgoron.weight-balanced-trees.internal.scm (renamed from doc/mcgoron.weight-balanced-trees.scm)16
-rw-r--r--mcgoron.weight-balanced-trees.internal.scm (renamed from mcgoron.weight-balanced-trees.scm)0
-rw-r--r--mcgoron.weight-balanced-trees.internal.sld (renamed from mcgoron.weight-balanced-trees.sld)4
-rw-r--r--tests/run.scm19
-rw-r--r--weight-balanced-trees.egg6
6 files changed, 34 insertions, 17 deletions
diff --git a/README.md b/README.md
index 2cca231..416199b 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,6 @@
# Weight Balanced Trees
[Weight Balanced Trees][1] with an SRFI interface. Implementation based on
-["Balancing Weight Balanced Trees"][2] by Yoichi Hirai and Kazuhiko
-Yamamoto.
+[Parallel Ordered Sets Using Join][1].
-[1]: https://en.wikipedia.org/wiki/Weight-balanced_tree
-[2]: https://yoichihirai.com/bst.pdf
+[1]: https://arxiv.org/abs/1602.02120
diff --git a/doc/mcgoron.weight-balanced-trees.scm b/doc/mcgoron.weight-balanced-trees.internal.scm
index 0bebb3d..5812d72 100644
--- a/doc/mcgoron.weight-balanced-trees.scm
+++ b/doc/mcgoron.weight-balanced-trees.internal.scm
@@ -31,4 +31,18 @@ Returns a weight-balanced tree where the elements of the tree are the
elements of `x`."))
((name . "node->in-order-list")
(signature lambda ((wb-tree-node? x)) => list?)
- (desc "Returns a list of all elements of `x` in order."))) \ No newline at end of file
+ (desc "Returns a list of all elements of `x` in order."))
+ ((name . "join")
+ (signature lambda (data (wb-tree-node? left) (wb-tree-node? right))
+ => non-null-wb-tree-node?)
+ (desc "
+* It is an error if `left` or `right` are not balanced.
+* It is an error if any element of `left` is greater than or equal to
+ any element in `right`.
+* It is an error if `data` is less than or equal to any element in
+ `left`.
+* It is an error if `data` is greater than or equal to any element in
+ `right`.
+
+Returns a balanced tree containing all elements of `left` and `right`
+with `data`."))) \ No newline at end of file
diff --git a/mcgoron.weight-balanced-trees.scm b/mcgoron.weight-balanced-trees.internal.scm
index a3c9059..a3c9059 100644
--- a/mcgoron.weight-balanced-trees.scm
+++ b/mcgoron.weight-balanced-trees.internal.scm
diff --git a/mcgoron.weight-balanced-trees.sld b/mcgoron.weight-balanced-trees.internal.sld
index 2cdee36..f5f5362 100644
--- a/mcgoron.weight-balanced-trees.sld
+++ b/mcgoron.weight-balanced-trees.internal.sld
@@ -13,7 +13,7 @@
| limitations under the License.
|#
-(define-library (mcgoron weight-balanced-trees)
+(define-library (mcgoron weight-balanced-trees internal)
(import (scheme base))
(cond-expand
;; Handle type declarations
@@ -28,5 +28,5 @@
in-order-vector->node
node->in-order-list
join)
- (include "mcgoron.weight-balanced-trees.scm"))
+ (include "mcgoron.weight-balanced-trees.internal.scm"))
diff --git a/tests/run.scm b/tests/run.scm
index b7d78d3..a280233 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -13,14 +13,17 @@
| limitations under the License.
|#
-(import (mcgoron weight-balanced-trees)
+(import (mcgoron weight-balanced-trees internal)
(prefix (only (mcgoron srfi 64) factory) mcgoron-test-)
(except (mcgoron srfi 64) factory)
(srfi 1) (srfi 26) (srfi 64) (srfi 128) (srfi 132) (srfi 133)
(srfi 158) (srfi 194) (srfi 197) (srfi 252))
-(define verbose
- (make-parameter #f))
+;;; ;;;;;;;;;;;;;;;;
+;;; Parameters
+
+(define verbose (make-parameter #f))
+(define max-vector-length (make-parameter 100))
;;; ;;;;;;;;;;;;;;;;;;;;
;;; Setup my test runner
@@ -101,11 +104,12 @@
(dynamic-property-set! 'lst lst))
(equal? (vector->list vec) lst)))
(test-property vector->node->list?
- (list (in-order-vector-generator 50))))
+ (list (in-order-vector-generator (max-vector-length)))))
(test-group "vector->node balanced?"
(test-assert (balanced? '()))
- (test-property balanced? (list (vector->node-generator 50))))
+ (test-property balanced? (list (vector->node-generator
+ (max-vector-length)))))
;;; ;;;;;;;;;
;;; Test that join preserves the order of nodes
@@ -151,7 +155,8 @@
(test-group "join-preserves-order-of"
(parameterize ((verbose #f))
- (test-property join-preserves-order-of (list (split-vector-generator 50)))))
+ (test-property join-preserves-order-of (list (split-vector-generator
+ (max-vector-length))))))
(test-group "join balanced?"
(define (join-split-vectors vec)
@@ -163,4 +168,4 @@
(in-order-vector->node right))))
(define (joined-vector-generator of)
(gmap join-split-vectors (split-vector-generator of)))
- (test-property balanced? (list (joined-vector-generator 50))))
+ (test-property balanced? (list (joined-vector-generator (max-vector-length)))))
diff --git a/weight-balanced-trees.egg b/weight-balanced-trees.egg
index b5cc6e2..273a998 100644
--- a/weight-balanced-trees.egg
+++ b/weight-balanced-trees.egg
@@ -5,7 +5,7 @@
(license "Apache-2.0")
(dependencies "r7rs" "srfi-128")
(test-dependencies "srfi-133" "srfi-132" "srfi-194" "srfi-132" "srfi-128" "srfi-1" "srfi-64" "srfi-252" "srfi-158" "sexpr-srfi-64-runner" "srfi-197")
- (components (extension mcgoron.weight-balanced-trees
- (source "mcgoron.weight-balanced-trees.sld")
- (source-dependencies "mcgoron.weight-balanced-trees.scm")
+ (components (extension mcgoron.weight-balanced-trees.internal
+ (source "mcgoron.weight-balanced-trees.internal.sld")
+ (source-dependencies "mcgoron.weight-balanced-trees.internal.scm")
(csc-options "-R" "r7rs" "-X" "r7rs"))))