avl_tree 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +42 -0
- data/bench/bench_thread.rb +39 -0
- data/lib/avl_tree.rb +4 -0
- data/lib/red_black_tree.rb +334 -38
- data/test/coverage/assets/0.8.0/application.css +799 -0
- data/test/coverage/assets/0.8.0/application.js +1559 -0
- data/test/coverage/assets/0.8.0/colorbox/border.png +0 -0
- data/test/coverage/assets/0.8.0/colorbox/controls.png +0 -0
- data/test/coverage/assets/0.8.0/colorbox/loading.gif +0 -0
- data/test/coverage/assets/0.8.0/colorbox/loading_background.png +0 -0
- data/test/coverage/assets/0.8.0/favicon_green.png +0 -0
- data/test/coverage/assets/0.8.0/favicon_red.png +0 -0
- data/test/coverage/assets/0.8.0/favicon_yellow.png +0 -0
- data/test/coverage/assets/0.8.0/loading.gif +0 -0
- data/test/coverage/assets/0.8.0/magnify.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/test/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/coverage/index.html +72 -0
- data/test/test_avl_tree.rb +37 -0
- data/test/test_red_black_tree.rb +61 -45
- data/test/test_red_black_tree_thread.rb +39 -0
- metadata +40 -21
- data/README +0 -16
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>Code coverage for Test</title>
|
5
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
+
<script src='./assets/0.8.0/application.js' type='text/javascript'></script>
|
7
|
+
<link href='./assets/0.8.0/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="shortcut icon" type="image/png" href="./assets/0.8.0/favicon_green.png" />
|
9
|
+
<link rel="icon" type="image/png" href="./assets/0.8.0/favicon.png" />
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<div id="loading">
|
14
|
+
<img src="./assets/0.8.0/loading.gif" alt="loading"/>
|
15
|
+
</div>
|
16
|
+
<div id="wrapper" style="display:none;">
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2014-09-27T15:56:00+09:00">2014-09-27T15:56:00+09:00</abbr></div>
|
18
|
+
<ul class="group_tabs"></ul>
|
19
|
+
|
20
|
+
<div id="content">
|
21
|
+
<div class="file_list_container" id="AllFiles">
|
22
|
+
<h2>
|
23
|
+
<span class="group_name">All Files</span>
|
24
|
+
(<span class="covered_percent"><span class="green">100.0%</span></span>
|
25
|
+
covered at
|
26
|
+
<span class="covered_strength">
|
27
|
+
<span class="red">
|
28
|
+
0.0
|
29
|
+
</span>
|
30
|
+
</span> hits/line)
|
31
|
+
</h2>
|
32
|
+
<a name="AllFiles"></a>
|
33
|
+
<div>
|
34
|
+
<b>0</b> files in total.
|
35
|
+
<b>0.0</b> relevant lines.
|
36
|
+
<span class="green"><b>0.0</b> lines covered</span> and
|
37
|
+
<span class="red"><b>0.0</b> lines missed </span>
|
38
|
+
</div>
|
39
|
+
<table class="file_list">
|
40
|
+
<thead>
|
41
|
+
<tr>
|
42
|
+
<th>File</th>
|
43
|
+
<th>% covered</th>
|
44
|
+
<th>Lines</th>
|
45
|
+
<th>Relevant Lines</th>
|
46
|
+
<th>Lines covered</th>
|
47
|
+
<th>Lines missed</th>
|
48
|
+
<th>Avg. Hits / Line</th>
|
49
|
+
</tr>
|
50
|
+
</thead>
|
51
|
+
<tbody>
|
52
|
+
|
53
|
+
</tbody>
|
54
|
+
</table>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<div id="footer">
|
62
|
+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.8.2
|
63
|
+
and simplecov-html v0.8.0<br/>
|
64
|
+
using Unit Tests
|
65
|
+
</div>
|
66
|
+
|
67
|
+
<div class="source_files">
|
68
|
+
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</body>
|
72
|
+
</html>
|
data/test/test_avl_tree.rb
CHANGED
@@ -458,6 +458,43 @@ class TestAVLTree < Test::Unit::TestCase
|
|
458
458
|
assert_equal [], h.values
|
459
459
|
end
|
460
460
|
|
461
|
+
def test_height
|
462
|
+
h = AVLTree.new
|
463
|
+
assert_equal 0, h.height
|
464
|
+
h[1] = true
|
465
|
+
assert_equal 1, h.height
|
466
|
+
h[2] = true
|
467
|
+
assert_equal 2, h.height
|
468
|
+
h[3] = true
|
469
|
+
assert_equal 2, h.height
|
470
|
+
h[4] = true
|
471
|
+
assert_equal 3, h.height
|
472
|
+
h[5] = true
|
473
|
+
assert_equal 3, h.height
|
474
|
+
h[6] = true
|
475
|
+
assert_equal 3, h.height
|
476
|
+
h[7] = true
|
477
|
+
assert_equal 3, h.height
|
478
|
+
h[8] = true
|
479
|
+
assert_equal 4, h.height
|
480
|
+
h.delete(8)
|
481
|
+
assert_equal 3, h.height
|
482
|
+
h.delete(7)
|
483
|
+
assert_equal 3, h.height
|
484
|
+
h.delete(6)
|
485
|
+
assert_equal 3, h.height
|
486
|
+
h.delete(5)
|
487
|
+
assert_equal 3, h.height
|
488
|
+
h.delete(4)
|
489
|
+
assert_equal 2, h.height
|
490
|
+
h.delete(3)
|
491
|
+
assert_equal 2, h.height
|
492
|
+
h.delete(2)
|
493
|
+
assert_equal 1, h.height
|
494
|
+
h.delete(1)
|
495
|
+
assert_equal 0, h.height
|
496
|
+
end
|
497
|
+
|
461
498
|
if RUBY_VERSION >= '1.9.0'
|
462
499
|
# In contrast to RadixTree, AVLTree just uses String#<=> as-is
|
463
500
|
def test_encoding
|
data/test/test_red_black_tree.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require File.expand_path('./helper', File.dirname(__FILE__))
|
3
3
|
|
4
|
-
|
4
|
+
module RedBlackTreeTest
|
5
5
|
def __test_random
|
6
|
-
h =
|
6
|
+
h = create_test_target
|
7
7
|
10000.times do |idx|
|
8
8
|
key = rand(100)
|
9
9
|
h[key] = key
|
@@ -13,7 +13,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_tree_rotate_RR
|
16
|
-
h =
|
16
|
+
h = create_test_target
|
17
17
|
assert_equal '', h.dump_sexp
|
18
18
|
h['a'] = 1
|
19
19
|
assert_equal 'a', h.dump_sexp
|
@@ -28,7 +28,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_tree_rotate_LL
|
31
|
-
h =
|
31
|
+
h = create_test_target
|
32
32
|
h['e'] = 1
|
33
33
|
h['d'] = 2
|
34
34
|
assert_equal '(e d)', h.dump_sexp
|
@@ -41,7 +41,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_tree_rotate_RL
|
44
|
-
h =
|
44
|
+
h = create_test_target
|
45
45
|
h['b'] = 1
|
46
46
|
h['a'] = 2
|
47
47
|
h['g'] = 3
|
@@ -57,7 +57,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_tree_rotate_LR
|
60
|
-
h =
|
60
|
+
h = create_test_target
|
61
61
|
h['g'] = 1
|
62
62
|
h['b'] = 2
|
63
63
|
h['h'] = 3
|
@@ -73,13 +73,13 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_aref_nil
|
76
|
-
h =
|
76
|
+
h = create_test_target
|
77
77
|
h['abc'] = 1
|
78
78
|
assert_equal nil, h['def']
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_empty
|
82
|
-
h =
|
82
|
+
h = create_test_target
|
83
83
|
h['abc'] = 0
|
84
84
|
assert_equal nil, h['']
|
85
85
|
h[''] = 1
|
@@ -89,13 +89,13 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_aref_single
|
92
|
-
h =
|
92
|
+
h = create_test_target
|
93
93
|
h['abc'] = 1
|
94
94
|
assert_equal 1, h['abc']
|
95
95
|
end
|
96
96
|
|
97
97
|
def test_aref_double
|
98
|
-
h =
|
98
|
+
h = create_test_target
|
99
99
|
h['abc'] = 1
|
100
100
|
h['def'] = 2
|
101
101
|
assert_equal 1, h['abc']
|
@@ -103,14 +103,14 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def test_aset_override
|
106
|
-
h =
|
106
|
+
h = create_test_target
|
107
107
|
h['abc'] = 1
|
108
108
|
h['abc'] = 2
|
109
109
|
assert_equal 2, h['abc']
|
110
110
|
end
|
111
111
|
|
112
112
|
def test_split
|
113
|
-
h =
|
113
|
+
h = create_test_target
|
114
114
|
h['abcd'] = 1
|
115
115
|
assert_equal 1, h['abcd']
|
116
116
|
h['abce'] = 2
|
@@ -128,7 +128,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_split_and_assign
|
131
|
-
h =
|
131
|
+
h = create_test_target
|
132
132
|
h['ab'] = 1
|
133
133
|
h['a'] = 2
|
134
134
|
assert_equal 1, h['ab']
|
@@ -136,7 +136,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def test_push
|
139
|
-
h =
|
139
|
+
h = create_test_target
|
140
140
|
assert_equal 0, h.size
|
141
141
|
h['a'] = 1
|
142
142
|
assert_equal 1, h['a']
|
@@ -170,7 +170,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
170
170
|
end
|
171
171
|
|
172
172
|
def test_different_type
|
173
|
-
h =
|
173
|
+
h = create_test_target
|
174
174
|
h['a'] = 1
|
175
175
|
assert_raise(TypeError) do
|
176
176
|
h[3.3] = 2
|
@@ -179,7 +179,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def test_delete_leaf
|
182
|
-
h =
|
182
|
+
h = create_test_target
|
183
183
|
h['b'] = 1
|
184
184
|
h['a'] = 2
|
185
185
|
h['c'] = 3
|
@@ -189,7 +189,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
189
189
|
end
|
190
190
|
|
191
191
|
def test_delete_leaf_single_rotation
|
192
|
-
h =
|
192
|
+
h = create_test_target
|
193
193
|
h['b'] = 1
|
194
194
|
h['a'] = 2
|
195
195
|
h['d'] = 3
|
@@ -201,7 +201,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
201
201
|
end
|
202
202
|
|
203
203
|
def test_delete_leaf_single_rotation_right
|
204
|
-
h =
|
204
|
+
h = create_test_target
|
205
205
|
h['d'] = 1
|
206
206
|
h['e'] = 2
|
207
207
|
h['b'] = 3
|
@@ -213,7 +213,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def test_delete_leaf_double_rotation
|
216
|
-
h =
|
216
|
+
h = create_test_target
|
217
217
|
h['b'] = 1
|
218
218
|
h['a'] = 2
|
219
219
|
h['e'] = 3
|
@@ -229,7 +229,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
229
229
|
end
|
230
230
|
|
231
231
|
def test_delete_leaf_double_rotation_right
|
232
|
-
h =
|
232
|
+
h = create_test_target
|
233
233
|
h['d'] = 1
|
234
234
|
h['e'] = 2
|
235
235
|
h['a'] = 3
|
@@ -245,7 +245,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def test_delete_node_right
|
248
|
-
h =
|
248
|
+
h = create_test_target
|
249
249
|
h['c'] = 1
|
250
250
|
h['b'] = 2
|
251
251
|
h['g'] = 3
|
@@ -262,7 +262,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
262
262
|
end
|
263
263
|
|
264
264
|
def test_delete_node_left
|
265
|
-
h =
|
265
|
+
h = create_test_target
|
266
266
|
h['h'] = 1
|
267
267
|
h['i'] = 2
|
268
268
|
h['d'] = 3
|
@@ -279,7 +279,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
279
279
|
end
|
280
280
|
|
281
281
|
def test_delete_root
|
282
|
-
h =
|
282
|
+
h = create_test_target
|
283
283
|
h['b'] = 1
|
284
284
|
h['a'] = 2
|
285
285
|
h['c'] = 3
|
@@ -291,7 +291,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
291
291
|
end
|
292
292
|
|
293
293
|
def test_delete
|
294
|
-
h =
|
294
|
+
h = create_test_target
|
295
295
|
h['a'] = 1
|
296
296
|
h['ab'] = 2
|
297
297
|
h['abc'] = 3
|
@@ -337,7 +337,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
337
337
|
end
|
338
338
|
|
339
339
|
def test_delete_right
|
340
|
-
h =
|
340
|
+
h = create_test_target
|
341
341
|
h['f'] = 1
|
342
342
|
h['e'] = 2
|
343
343
|
h['d'] = 3
|
@@ -383,7 +383,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
383
383
|
end
|
384
384
|
|
385
385
|
def test_delete_compaction_middle
|
386
|
-
h =
|
386
|
+
h = create_test_target
|
387
387
|
h['a'] = 1
|
388
388
|
h['abc'] = 2
|
389
389
|
h['bb'] = 3
|
@@ -398,7 +398,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
398
398
|
end
|
399
399
|
|
400
400
|
def test_delete_compaction_leaf
|
401
|
-
h =
|
401
|
+
h = create_test_target
|
402
402
|
h['a'] = 1
|
403
403
|
h['abc'] = 2
|
404
404
|
h['bb'] = 3
|
@@ -413,7 +413,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
413
413
|
end
|
414
414
|
|
415
415
|
def test_delete_balanced_rotate_left
|
416
|
-
h =
|
416
|
+
h = create_test_target
|
417
417
|
h['f'] = 1
|
418
418
|
h['c'] = 100
|
419
419
|
h['l'] = 1
|
@@ -440,7 +440,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
440
440
|
end
|
441
441
|
|
442
442
|
def test_delete_balanced_rotate_right
|
443
|
-
h =
|
443
|
+
h = create_test_target
|
444
444
|
h['i'] = 1
|
445
445
|
h['l'] = 100
|
446
446
|
h['c'] = 1
|
@@ -467,7 +467,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
467
467
|
end
|
468
468
|
|
469
469
|
def test_delete_different_type
|
470
|
-
h =
|
470
|
+
h = create_test_target
|
471
471
|
h['a'] = 1
|
472
472
|
h['abc'] = 2
|
473
473
|
h['bb'] = 3
|
@@ -478,7 +478,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
478
478
|
end
|
479
479
|
|
480
480
|
def test_each
|
481
|
-
h =
|
481
|
+
h = create_test_target
|
482
482
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
483
483
|
s.each do |k, v|
|
484
484
|
h[k] = v
|
@@ -493,7 +493,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
493
493
|
end
|
494
494
|
|
495
495
|
def test_each_key
|
496
|
-
h =
|
496
|
+
h = create_test_target
|
497
497
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
498
498
|
s.each do |k, v|
|
499
499
|
h[k] = v
|
@@ -508,7 +508,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
508
508
|
end
|
509
509
|
|
510
510
|
def test_each_value
|
511
|
-
h =
|
511
|
+
h = create_test_target
|
512
512
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6, 'azzzzz' => 6 }
|
513
513
|
s.each do |k, v|
|
514
514
|
h[k] = v
|
@@ -523,7 +523,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
523
523
|
end
|
524
524
|
|
525
525
|
def test_keys
|
526
|
-
h =
|
526
|
+
h = create_test_target
|
527
527
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
528
528
|
s.each do |k, v|
|
529
529
|
h[k] = v
|
@@ -532,7 +532,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
532
532
|
end
|
533
533
|
|
534
534
|
def test_values
|
535
|
-
h =
|
535
|
+
h = create_test_target
|
536
536
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
537
537
|
s.each do |k, v|
|
538
538
|
h[k] = v
|
@@ -541,14 +541,14 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
541
541
|
end
|
542
542
|
|
543
543
|
def test_to_s
|
544
|
-
h =
|
544
|
+
h = create_test_target
|
545
545
|
h[5] = 1
|
546
546
|
assert_equal 1, h[5]
|
547
547
|
assert_nil h["5"]
|
548
548
|
end
|
549
549
|
|
550
550
|
def test_key?
|
551
|
-
h =
|
551
|
+
h = create_test_target
|
552
552
|
assert !h.key?('a')
|
553
553
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
554
554
|
s.each do |k, v|
|
@@ -559,22 +559,22 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
559
559
|
|
560
560
|
def test_default
|
561
561
|
assert_raise(ArgumentError) do
|
562
|
-
|
562
|
+
create_test_target('both') { :not_allowed }
|
563
563
|
end
|
564
564
|
|
565
|
-
h =
|
565
|
+
h = create_test_target('abc')
|
566
566
|
assert_equal 'abc', h['foo']
|
567
567
|
assert_equal 'abc', h['bar']
|
568
568
|
assert h['baz'].object_id == h['qux'].object_id
|
569
569
|
|
570
|
-
h =
|
570
|
+
h = create_test_target { [1, 2] }
|
571
571
|
assert_equal [1, 2], h['foo']
|
572
572
|
assert_equal [1, 2], h['bar']
|
573
573
|
assert h['baz'].object_id != h['qux'].object_id
|
574
574
|
end
|
575
575
|
|
576
576
|
def test_to_hash
|
577
|
-
h =
|
577
|
+
h = create_test_target
|
578
578
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
579
579
|
s.each do |k, v|
|
580
580
|
h[k] = v
|
@@ -583,7 +583,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
583
583
|
end
|
584
584
|
|
585
585
|
def test_clear
|
586
|
-
h =
|
586
|
+
h = create_test_target
|
587
587
|
s = { 'aa' => 1, 'ab' => 2, 'bb' => 3, 'bc' => 4, 'a' => 5, 'abc' => 6 }
|
588
588
|
s.each do |k, v|
|
589
589
|
h[k] = v
|
@@ -595,7 +595,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
595
595
|
end
|
596
596
|
|
597
597
|
def test_non_string_keys
|
598
|
-
h =
|
598
|
+
h = create_test_target
|
599
599
|
h[1.3] = 'a'
|
600
600
|
h[4.3] = 'b'
|
601
601
|
|
@@ -603,7 +603,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
603
603
|
end
|
604
604
|
|
605
605
|
def test_values_for_empty_tree
|
606
|
-
h =
|
606
|
+
h = create_test_target
|
607
607
|
|
608
608
|
assert_equal [], h.values
|
609
609
|
end
|
@@ -611,7 +611,7 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
611
611
|
if RUBY_VERSION >= '1.9.0'
|
612
612
|
# In contrast to RadixTree, RedBlackTree just uses String#<=> as-is
|
613
613
|
def test_encoding
|
614
|
-
h =
|
614
|
+
h = create_test_target
|
615
615
|
s = { '$B$"$"(B' => 1, '$B$"$$(B' => 2, '$B$$$$(B' => 3, '$B$$$&(B' => 4, '$B$"(B' => 5, '$B$"$$$&(B' => 6 }
|
616
616
|
s.each do |k, v|
|
617
617
|
h[k] = v
|
@@ -627,3 +627,19 @@ class TestRedBlackTree < Test::Unit::TestCase
|
|
627
627
|
end
|
628
628
|
end
|
629
629
|
end
|
630
|
+
|
631
|
+
class TestRedBlackTree < Test::Unit::TestCase
|
632
|
+
include RedBlackTreeTest
|
633
|
+
|
634
|
+
def create_test_target(*a, &b)
|
635
|
+
RedBlackTree.new(*a, &b)
|
636
|
+
end
|
637
|
+
end
|
638
|
+
|
639
|
+
class TestConcurrentRedBlackTree < Test::Unit::TestCase
|
640
|
+
include RedBlackTreeTest
|
641
|
+
|
642
|
+
def create_test_target(*a, &b)
|
643
|
+
ConcurrentRedBlackTree.new(*a, &b)
|
644
|
+
end
|
645
|
+
end
|