提供红黑树的移动构造和移动赋值函数,并删除拷贝构造以及拷贝赋值
This commit is contained in:
@@ -118,6 +118,24 @@ namespace ling {
|
||||
public:
|
||||
explicit RedBlackTree() = default;
|
||||
|
||||
RedBlackTree(const RedBlackTree &other) = delete;
|
||||
|
||||
RedBlackTree(RedBlackTree &&other) noexcept {
|
||||
this->rootNode = other.rootNode;
|
||||
other.rootNode = nullptr;
|
||||
}
|
||||
|
||||
RedBlackTree &operator=(RedBlackTree &&other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
this->rootNode = other.rootNode;
|
||||
other.rootNode = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RedBlackTree &operator=(const RedBlackTree &other) = delete;
|
||||
|
||||
virtual ~RedBlackTree() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user