Microscopic Traffic Simulator
LimitedStepsCellWalker.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 
3 namespace Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.CellWalkers
4 {
9  {
13  private int max;
14 
18  protected int i;
19 
23  private CellWalker cellWalker;
24 
28  internal int CellsWalked { get { return max - i; } }
29 
35  internal LimitedStepsCellWalker(CellWalker cellWalker, int max)
36  {
37  this.cellWalker = cellWalker;
38  this.i = this.max = max;
39  }
40 
45  internal virtual IEnumerable<Cell> GetNext()
46  {
47  foreach (Cell cell in cellWalker.GetNext())
48  if (i-- > 0 && cell.Sensor == null)
49  yield return cell;
50  else
51  yield break;
52  }
53  }
54 }
Abstract class for returning cells by walking through topology.
Definition: CellWalker.cs:8
Class wrapping a cell walker and applying limit to number of walked cells.