Skip to content

Commit 9080d67

Browse files
committed
Update helper functions
1 parent 2be564a commit 9080d67

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/avl.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,8 @@ function _updateheight!(node)
187187
node
188188
end
189189

190-
_height(::Nothing) = 0
191-
_height(node::AVLNode) = node.height
190+
_height(node) = isnothing(node) ? 0 : node.height
192191

193-
_balancefactor(::Nothing) = 0
194-
_balancefactor(node::AVLNode) = _height(node.left) - _height(node.right)
192+
_balancefactor(node) = isnothing(node) ? 0 : _height(node.left) - _height(node.right)
195193

196-
_minnode(::Nothing) = nothing
197-
_minnode(node::AVLNode) = isnothing(node.left) ? node : _minnode(node.left)
194+
_minnode(node) = isnothing(node) || isnothing(node.left) ? node : _minnode(node.left)

0 commit comments

Comments
 (0)