|
@@ -8,12 +8,6 @@ import "core:mem"
|
|
|
import "core:slice"
|
|
|
import "core:log"
|
|
|
|
|
|
-@(private)
|
|
|
-_RANDOM_SEED :: #config(RANDOM_SEED, u64(0))
|
|
|
-
|
|
|
-// Exported
|
|
|
-random_seed := u64(intrinsics.read_cycle_counter()) when _RANDOM_SEED == 0 else u64(_RANDOM_SEED)
|
|
|
-
|
|
|
test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) {
|
|
|
track: mem.Tracking_Allocator
|
|
|
mem.tracking_allocator_init(&track, context.allocator)
|
|
@@ -21,9 +15,9 @@ test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) {
|
|
|
context.allocator = mem.tracking_allocator(&track)
|
|
|
|
|
|
r: rand.Rand
|
|
|
- rand.init(&r, random_seed)
|
|
|
+ rand.init(&r, t.seed)
|
|
|
|
|
|
- log.infof("Testing Red-Black Tree($Key=%v,$Value=%v), using random seed %v, add -define:RANDOM_SEED=%v to reuse it.", type_info_of(Key), type_info_of(Value), random_seed, random_seed)
|
|
|
+ log.infof("Testing Red-Black Tree($Key=%v,$Value=%v) using random seed %v.", type_info_of(Key), type_info_of(Value), t.seed)
|
|
|
tree: rb.Tree(Key, Value)
|
|
|
rb.init(&tree)
|
|
|
|
|
@@ -243,4 +237,4 @@ verify_rbtree_propery_5_helper :: proc(t: ^testing.T, n: ^$N/rb.Node($Key, $Valu
|
|
|
verify_rbtree_propery_5_helper(t, n._right, black_count, path_black_count)
|
|
|
}
|
|
|
// Properties 4 and 5 together guarantee that no path in the tree is more than about twice as long as any other path,
|
|
|
-// which guarantees that it has O(log n) height.
|
|
|
+// which guarantees that it has O(log n) height.
|