Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /* MSearchTree.h */
  2.  
  3. #include "TreeNode.h"
  4. #include <utility>
  5.  
  6. class MSearchTree {
  7. public:
  8. explicit MSearchTree(int m = 1) : m_(m) {}
  9. MSearchTree(const MSearchTree& other) { copy(other); }
  10. MSearchTree(MSearchTree&& other) { move(other); }
  11. ~MSearchTree() { destroy(); }
  12.  
  13. MSearchTree& operator=(const MSearchTree& other)
  14. {
  15. if (this != &other) { destroy(); copy(other); }
  16. return *this;
  17. }
  18.  
  19. MSearchTree& operator=(MSearchTree&& other)
  20. {
  21. if (this != &other) { destroy(); move(other); }
  22. return *this;
  23. }
  24.  
  25. private:
  26. int m_;
  27. TreeNode* root_;
  28.  
  29. void copy(const MSearchTree& other);
  30. void move(MSearchTree& other);
  31. void destroy();
  32. }
  33.  
  34.  
  35. /* MSearchTree.cpp */
  36.  
  37. #include "MSearchTree.h"
  38.  
  39. void MSearchTree::copy(const MSearchTree& other)
  40. {
  41. // preorder kopiranje
  42. }
  43.  
  44. inline void MSearchTree::move(MSearchTree& other)
  45. {
  46. m_ = other.m_;
  47. root_ = std::exchange(other.root_, nullptr);
  48. }
  49.  
  50. void MSearchTree::destroy()
  51. {
  52. // postorder uništavanje
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement