TNaryTree.hpp 867 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef _TNARYTREE_HPP_
  2. #define _TNARYTREE_HPP_
  3. #include <string>
  4. #include "hexagon.hpp"
  5. class TNaryTree {
  6. private:
  7. struct ItemTree {
  8. ItemTree* son;
  9. ItemTree* brother;
  10. Hexagon figure;
  11. int current_size;
  12. ItemTree() {}
  13. };
  14. public:
  15. TNaryTree();
  16. TNaryTree(int n);
  17. void Update(Hexagon& polygon, const std::string& tree_path = "");
  18. const Hexagon& GetItem(const std::string& tree_path = "");
  19. void RemoveSubTree(const std::string& tree_path);
  20. bool Empty();
  21. friend std::ostream& operator<<(std::ostream& os, const TNaryTree& tree);
  22. virtual ~TNaryTree();
  23. private:
  24. int size;
  25. ItemTree* root;
  26. void delete_node(ItemTree* t);
  27. void Print(ItemTree* t) const;
  28. };
  29. #endif // _TNARYTREE_HPP_