File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ function Base.push!(tree::AVLTree{K}, key0) where K
191
191
insert! (tree, key)
192
192
end
193
193
194
- function delete_node! (node:: AVLTreeNode{K} , key) where K
194
+ function delete_node! (node:: AVLTreeNode{K} , key:: K ) where K
195
195
if key < node. data
196
196
node. leftChild = delete_node! (node. leftChild, key)
197
197
elseif key > node. data
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ tests = ["deprecations",
34
34
" dibit_vector" ,
35
35
" swiss_dict" ,
36
36
" avl_tree" ,
37
- " red_black_tree" ,
37
+ " red_black_tree" ,
38
38
" splay_tree"
39
39
]
40
40
Original file line number Diff line number Diff line change 26
26
end
27
27
28
28
@test length (t) == 50
29
-
29
+
30
30
for i in 1 : 100
31
31
if iseven (i)
32
32
@test haskey (t, i)
43
43
end
44
44
45
45
@testset " handling different cases of delete!" begin
46
- t2 = AVLTree ()
46
+ t2 = AVLTree {Int} ()
47
47
for i in 1 : 100000
48
48
insert! (t2, i)
49
49
end
50
50
51
51
@test length (t2) == 100000
52
-
52
+
53
53
nums = rand (1 : 100000 , 8599 )
54
54
visited = Set ()
55
- for num in nums
55
+ for num in nums
56
56
if ! (num in visited)
57
57
delete! (t2, num)
58
- push! (visited, num)
58
+ push! (visited, num)
59
59
end
60
60
end
61
61
67
67
68
68
@testset " handling different cases of insert!" begin
69
69
nums = rand (1 : 100000 , 1000 )
70
- t3 = AVLTree ()
70
+ t3 = AVLTree {Int} ()
71
71
uniq_nums = Set (nums)
72
72
for num in uniq_nums
73
73
insert! (t3, num)
84
84
@test ! in (' c' , t4)
85
85
end
86
86
87
- @testset " search_node" begin
88
- t5 = AVLTree ()
87
+ @testset " search_node" begin
88
+ t5 = AVLTree {Int} ()
89
89
for i in 1 : 32
90
90
push! (t5, i)
91
91
end
92
92
n1 = search_node (t5, 21 )
93
93
@test n1. data == 21
94
94
n2 = search_node (t5, 35 )
95
- @test n2. data == 32
95
+ @test n2. data == 32
96
96
n3 = search_node (t5, 0 )
97
97
@test n3. data == 1
98
- end
98
+ end
99
99
100
- @testset " getindex" begin
100
+ @testset " getindex" begin
101
101
t6 = AVLTree {Int} ()
102
102
for i in 1 : 10
103
103
push! (t6, i)
117
117
end
118
118
119
119
@testset " minimum_node" begin
120
- t8 = AVLTree ()
120
+ t8 = AVLTree {Int} ()
121
121
@test minimum_node (t8. root) == nothing
122
122
for i in 1 : 32
123
123
push! (t8, i)
132
132
end
133
133
end
134
134
135
- @testset " rank" begin
135
+ @testset " rank" begin
136
136
t9 = AVLTree {Int} ()
137
137
for i in 1 : 20
138
138
push! (t9, i)
142
142
end
143
143
@test_throws KeyError sorted_rank (t9, 21 )
144
144
end
145
- end
145
+ end
You can’t perform that action at this time.
0 commit comments