ixfx
    Preparing search index...

    Function visitByNeighbours

    • Visits every cell in grid using supplied selection function In-built functions to use: visitorDepth, visitorBreadth, visitorRandom, visitorColumn, visitorRow.

      Usage example:

       let visitor = Grids.visitor(Grids.visitorRandom, grid, startCell);
      for (let cell of visitor) {
      // do something with cell
      }

      If you want to keep tabs on the visitor, pass in a Collections.Sets.ISetMutable instance. This gets updated as cells are visited to make sure we don't visit the same one twice. If a set is not passed in, one will be created internally.

      let visited = new SetStringMutable<Grids.Cell>(c => Grids.cellKeyString(c));
      let visitor = Grids.visitor(Grids.visitorRandom, grid, startCell, visited);

      To visit with some delay, try this pattern

       const delayMs = 100;
      const run = () => {
      let cell = visitor.next().value;
      if (cell === undefined) return;
      // Do something with cell
      setTimeout(run, delayMs);
      }
      setTimeout(run, delayMs);

      Parameters

      Returns Generator<Geometry.GridCell>

      Cells