#ifndef AVL_TREE #define AVL_TREE #include "Comparator.h" #include "AVLTreeEnumerator.h" template class AVLTree { template friend class AVLTreeEnumerator; private: Comparator* comparator = NULL; // used to determine tree order and item equality unsigned long size = 0; // actual number of items currently in tree T data{}; // data item of any type bool empty = true; // flag to indicate whether node contains data int diff = 0; // height of right minus height of left AVLTree* left = NULL; // pointer to left subtree AVLTree* right = NULL; // pointer to right subtree void zig(); // right rotation void zag(); // left rotation void zigzag(); // left rotation on left subtree, followed by right rotation void zagzig(); // right rotation on right subtree, followed by left rotation void rebalance(); // check for and rebalance this node, if needed public: AVLTree(Comparator* comparator); // creates empty linked tree with comparator virtual ~AVLTree(); // deletes subtrees // if an equivalent item is not already present, insert item in order and return true // if an equivalent item is already present, leave tree unchanged and return false bool insert(const T item); // if an equivalent item is already present, replace item and return true // if an equivalent item is not already present, leave tree unchanged and return false bool replace(const T item); // if an equivalent item is already present, remove item and return true // if an equivalent item is not already present, leave tree unchanged and return false bool remove(const T item); // if an equivalent item is present, return true // if an equivalent item is not present, false bool contains(T item) const; // if an equivalent item is present, return a copy of the item // if an equivalent item is not present, throw a new ExceptionLinkedtreeAccess T find(const T item) const; unsigned long getSize() const; // returns the current number of items in the tree AVLTreeEnumerator enumerator(AVLTreeOrder order = AVLTreeOrder::inorder) const; // create an enumerator for this AVL tree }; // Add your implementation below this line. #endif // !AVL_TREE