mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
fix rbtree memory error, check neel
This commit is contained in:
parent
9c70e36e1b
commit
de768296f1
|
@ -336,14 +336,14 @@ func (tree *RBTree) Rightmost() *RBNode {
|
|||
}
|
||||
|
||||
func (tree *RBTree) RightmostOf(current *RBNode) *RBNode {
|
||||
for current.Right != Neel {
|
||||
current = current.Right
|
||||
}
|
||||
|
||||
if current == Neel {
|
||||
return nil
|
||||
}
|
||||
|
||||
for current.Right != Neel {
|
||||
current = current.Right
|
||||
}
|
||||
|
||||
return current
|
||||
}
|
||||
|
||||
|
@ -352,18 +352,22 @@ func (tree *RBTree) Leftmost() *RBNode {
|
|||
}
|
||||
|
||||
func (tree *RBTree) LeftmostOf(current *RBNode) *RBNode {
|
||||
for current.Left != Neel {
|
||||
current = current.Left
|
||||
}
|
||||
|
||||
if current == Neel {
|
||||
return nil
|
||||
}
|
||||
|
||||
for current.Left != Neel {
|
||||
current = current.Left
|
||||
}
|
||||
|
||||
return current
|
||||
}
|
||||
|
||||
func (tree *RBTree) Successor(current *RBNode) *RBNode {
|
||||
if current == Neel {
|
||||
return nil
|
||||
}
|
||||
|
||||
if current.Right != Neel {
|
||||
return tree.LeftmostOf(current.Right)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user