public override void Iterate(ProcessData <T> pd, TRAVERSALORDER to) { if (nRoot != null) { RecIterate(nRoot, pd, to); } }
private void RecIterate(Node <T> nCurrent, ProcessData <T> pd, TRAVERSALORDER to) { if (to == TRAVERSALORDER.PRE_ORDER) { // Process the data in the current node pd(nCurrent.Data); } // If current's left child exists, recurse left if (nCurrent.Left != null) { RecIterate(nCurrent.Left, pd, to); } if (to == TRAVERSALORDER.IN_ORDER) { // Process the data in the current node pd(nCurrent.Data); } // If current's right child exists, recurse right if (nCurrent.Right != null) { RecIterate(nCurrent.Right, pd, to); } if (to == TRAVERSALORDER.POST_ORDER) { // Process the data in the current node pd(nCurrent.Data); } }
public abstract void Iterate(ProcessData <T> pd, TRAVERSALORDER to);