private void ForeachGridCell(TraverseMethod method) { for (int i = 0; i < GridSize [0]; i++) { for (int j = 0; j < GridSize [1]; j++) { method(i, j); } } }
private void TraverseThroughGrid(int x, int y, TraverseMethod method) { if (IsValidPosition(x, y) && !grid.Grid [x, y].visitedByAstar && GetState(x, y) != MaskState.UNUSED) { method(x, y); grid.Grid [x, y].visitedByAstar = true; TraverseThroughGrid(x - 1, y, method); TraverseThroughGrid(x, y - 1, method); TraverseThroughGrid(x + 1, y, method); TraverseThroughGrid(x, y + 1, method); } }
private void Traverse(Node <T> root, Action <T> action, TraverseMethod method) { switch (method) { case TraverseMethod.PreOrder: TraversePreOrder(root, action); break; case TraverseMethod.InOrder: TraverseInOrder(root, action); break; case TraverseMethod.PostOrder: TraversePostOrder(root, action); break; default: break; } }
private void TraverseThroughGrid(TraverseMethod method) { ForeachGridCell(ResetGridCell); TraverseThroughGrid(CenterIndices [0], CenterIndices [1], method); ForeachGridCell(UpdateInacessable); }
// Scan the whole tree, using the requested method, while // sending each node's data to the input delegate (Action<T>) public void TraverseTree(Action <T> action, TraverseMethod method = TraverseMethod.InOrder) { Traverse(_root, action, method); }