@@ -2,19 +2,17 @@ mutable struct SplayTreeNode{K}
2
2
leftChild:: Union{SplayTreeNode{K}, Nothing}
3
3
rightChild:: Union{SplayTreeNode{K}, Nothing}
4
4
parent:: Union{SplayTreeNode{K}, Nothing}
5
- dirty:: Bool
6
5
data:: K
7
6
8
- SplayTreeNode {K} () where K = new {K} (nothing , nothing , nothing , true )
9
- SplayTreeNode {K} (d:: K ) where K = new {K} (nothing , nothing , nothing , false , d)
7
+ SplayTreeNode {K} () where K = new {K} (nothing , nothing , nothing )
8
+ SplayTreeNode {K} (d:: K ) where K = new {K} (nothing , nothing , nothing , d)
10
9
end
11
10
12
11
SplayTreeNode_or_null{K} = Union{SplayTreeNode{K}, Nothing}
13
12
14
13
SplayTreeNode (d) = SplayTreeNode {Any} (d)
15
14
SplayTreeNode () = SplayTreeNode {Any} ()
16
15
17
- isdirty (node:: SplayTreeNode ) = node. dirty
18
16
19
17
mutable struct SplayTree{K}
20
18
root:: SplayTreeNode_or_null{K}
@@ -155,7 +153,7 @@ function search_key(tree::SplayTree{K}, d::K) where K
155
153
end
156
154
end
157
155
158
- function delete! (tree:: SplayTree{K} , d:: K ) where K
156
+ function Base . delete! (tree:: SplayTree{K} , d:: K ) where K
159
157
node = tree. root
160
158
x = search_by_node (node, d)
161
159
isa (x, Nothing) && return tree
@@ -180,7 +178,7 @@ function delete!(tree::SplayTree{K}, d::K) where K
180
178
return tree
181
179
end
182
180
183
- function insert! (tree:: SplayTree{K} , d:: K ) where K
181
+ function Base . insert! (tree:: SplayTree{K} , d:: K ) where K
184
182
is_present = search_by_node (tree. root, d)
185
183
if ! isa (is_present, Nothing) && (is_present. data == d)
186
184
return tree
0 commit comments