Ejemplo n.º 1
0
 private void ForeachGridCell(TraverseMethod method)
 {
     for (int i = 0; i < GridSize [0]; i++)
     {
         for (int j = 0; j < GridSize [1]; j++)
         {
             method(i, j);
         }
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 private void TraverseThroughGrid(TraverseMethod method)
 {
     ForeachGridCell(ResetGridCell);
     TraverseThroughGrid(CenterIndices [0], CenterIndices [1], method);
     ForeachGridCell(UpdateInacessable);
 }
Ejemplo n.º 5
0
 // 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);
 }