//
//  Tree.hpp
//  ADS P3
//

#pragma once
#include "TreeNode.h"
#include <string>

class Tree {

private:
	TreeNode* m_anker;
	int m_currentNodeChronologicalID;

	void deleteAll(TreeNode* _anker);
	bool isLeaf(TreeNode* _node);
	void balance(TreeNode* _node);
	bool split4Node(TreeNode* _node);
	void height();
	bool rotateTreeRight(TreeNode*, TreeNode*);
	bool rotateTreeLeft(TreeNode*, TreeNode*);
	void helpSearch(TreeNode* _anker, std::string _name, bool& _found);
	void printerHeader();
	void printer(TreeNode* _anker);
	void printLevel(TreeNode* _anker);

public:
	Tree();
	~Tree();

	int proofRBCriterion();
	int proofRBCriterion(TreeNode*);

	bool addNode(std::string _name, int _age, double _income, int _postCode);
	bool searchNode(std::string _name);

	void printAll(void);

	void print234Tree();
	void print234Tree(int niveau);

	void printLevelOrder();
	void printLevelOrder(int niveau);

	// friend-Funktionen sind für die Tests erforderlich und müssen unangetastet
	// bleiben!
	friend TreeNode* get_anker(Tree& TN);
};
