Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

LimitedStepsCellWalker.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2
3 namespace Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.CellWalkers
4 {
8 class LimitedStepsCellWalker
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 }
System
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.Cell
Class representing cell.
Definition: Cell.cs:9
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.CellWalkers.LimitedStepsCellWalker.i
int i
Current number of remaining walked cells
Definition: LimitedStepsCellWalker.cs:18
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.CellWalkers.CellWalker
Abstract class for returning cells by walking through topology.
Definition: CellWalker.cs:8
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.CellWalkers.LimitedStepsCellWalker
Class wrapping a cell walker and applying limit to number of walked cells.
Definition: LimitedStepsCellWalker.cs:8
Microscopic_Traffic_Simulator___Model