protected bool FindPath(PathElement peTo, PathElement pePrev, PathElement pe, int nNextElementSource, ArrayList alTrainPath) { Debug.Assert(pe != null); TrainCourse item = new TrainCourse { Element = pe, ElementSource = nNextElementSource }; alTrainPath.Add(item); if (peTo == pe) { return(true); } pePrev = pe; PathInfo[] nextPathsThrough = pePrev.GetNextPathsThrough(nNextElementSource); if (nextPathsThrough != null) { foreach (PathInfo info in nextPathsThrough) { if (info.ToElement != null) { int count = alTrainPath.Count; if (this.FindPath(peTo, pePrev, info.ToElement, info.ToSource, alTrainPath)) { return(true); } while (alTrainPath.Count > count) { alTrainPath.RemoveAt(alTrainPath.Count - 1); } } } } return(false); }
protected bool FindPath(PathElement peTo, PathElement pePrev, PathElement pe, int nNextElementSource, ArrayList alTrainPath) { Debug.Assert(pe != null); TrainCourse item = new TrainCourse { Element = pe, ElementSource = nNextElementSource }; alTrainPath.Add(item); if (peTo == pe) { return true; } pePrev = pe; PathInfo[] nextPathsThrough = pePrev.GetNextPathsThrough(nNextElementSource); if (nextPathsThrough != null) { foreach (PathInfo info in nextPathsThrough) { if (info.ToElement != null) { int count = alTrainPath.Count; if (this.FindPath(peTo, pePrev, info.ToElement, info.ToSource, alTrainPath)) { return true; } while (alTrainPath.Count > count) { alTrainPath.RemoveAt(alTrainPath.Count - 1); } } } } return false; }