修复红黑树内部的一个导致丢失节点的bug
This commit is contained in:
@@ -101,7 +101,7 @@ namespace ling {
|
||||
* lx rx rx ry
|
||||
*
|
||||
*/
|
||||
void rightRotate(Node *root, Node *y);
|
||||
void rightRotate(Node *&root, Node *y);
|
||||
|
||||
/// 查找元素
|
||||
Node *iterativeSearch(Node *x, T key) const;
|
||||
@@ -438,7 +438,7 @@ namespace ling {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void RedBlackTree<T>::rightRotate(RedBlackTree::Node *root, RedBlackTree::Node *y) {
|
||||
void RedBlackTree<T>::rightRotate(RedBlackTree::Node *&root, RedBlackTree::Node *y) {
|
||||
// 设置x是当前节点的左孩子。
|
||||
Node *x = y->left;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user