35class TreeIterator// abstract class from which each iterator type inherits
36{
37protected:
38constTreeTemplate<Node>& tree_; // The tree to iterate over its nodes. Can't be const because user should be allowed to edit the nodes of the tree during the traversal.
39constNode* currNode_; // A pointer to the current node visited by the iterator. Can't be const because user should be allowed to edit the nodes of the tree during the traversal.
40 map<int, bool> nodeToVisited_; // a map that matches to each node id of booleans that for each node id states if it is visited or not
41 map<int, bool> nodeToSonVisited_; // a map that matches to each node id if a son of his was visited or not
42 map<int, size_t> nodeToLastVisitedSonIndex_; // a map that matches to each node id the index of its last visited son visited son
48currNode_(tree.getRootNode()), // The pointer to the initial node is initialized as 0 since it's actual assignment depends on which traversal is chosen
64virtual~TreeIterator() {} // must be virtual to assume that upon deletion, the destructor of any inheriting class is called as well (see https://www.geeksforgeeks.org/virtual-destructor/)