We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2be564a commit 9080d67Copy full SHA for 9080d67
src/avl.jl
@@ -187,11 +187,8 @@ function _updateheight!(node)
187
node
188
end
189
190
-_height(::Nothing) = 0
191
-_height(node::AVLNode) = node.height
+_height(node) = isnothing(node) ? 0 : node.height
192
193
-_balancefactor(::Nothing) = 0
194
-_balancefactor(node::AVLNode) = _height(node.left) - _height(node.right)
+_balancefactor(node) = isnothing(node) ? 0 : _height(node.left) - _height(node.right)
195
196
-_minnode(::Nothing) = nothing
197
-_minnode(node::AVLNode) = isnothing(node.left) ? node : _minnode(node.left)
+_minnode(node) = isnothing(node) || isnothing(node.left) ? node : _minnode(node.left)
0 commit comments