Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* MSearchTree.h */
- #include "TreeNode.h"
- #include <utility>
- class MSearchTree {
- public:
- explicit MSearchTree(int m = 1) : m_(m) {}
- MSearchTree(const MSearchTree& other) { copy(other); }
- MSearchTree(MSearchTree&& other) { move(other); }
- ~MSearchTree() { destroy(); }
- MSearchTree& operator=(const MSearchTree& other)
- {
- if (this != &other) { destroy(); copy(other); }
- return *this;
- }
- MSearchTree& operator=(MSearchTree&& other)
- {
- if (this != &other) { destroy(); move(other); }
- return *this;
- }
- private:
- int m_;
- TreeNode* root_;
- void copy(const MSearchTree& other);
- void move(MSearchTree& other);
- void destroy();
- }
- /* MSearchTree.cpp */
- #include "MSearchTree.h"
- void MSearchTree::copy(const MSearchTree& other)
- {
- // preorder kopiranje
- }
- inline void MSearchTree::move(MSearchTree& other)
- {
- m_ = other.m_;
- root_ = std::exchange(other.root_, nullptr);
- }
- void MSearchTree::destroy()
- {
- // postorder uništavanje
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement