@ Pure public List < BusItineraryHalt > getBusHaltsOnSegment ( RoadSegment segment ) { if ( this . roadSegments . isEmpty ( ) || this . validHalts . isEmpty ( ) ) { return Collections . emptyList ( ) ; } int cIdxSegment ; int lIdxSegment = - 1 ; int sIdxSegment = - 1 ; RoadSegment cSegment ; final List < BusItineraryHalt > halts = new ArrayList <> ( ) ; for ( final BusItineraryHalt bushalt : this . validHalts ) { cIdxSegment = bushalt . getRoadSegmentIndex ( ) ; if ( cIdxSegment >= 0 && cIdxSegment < this . roadSegments . getRoadSegmentCount ( ) && cIdxSegment != lIdxSegment ) { cSegment = this . roadSegments . getRoadSegmentAt ( cIdxSegment ) ; lIdxSegment = cIdxSegment ; if ( segment == cSegment ) { sIdxSegment = cIdxSegment ; } else if ( sIdxSegment != - 1 ) { // halt loop now because I'm sure there has no more bus halt break ; } } if ( sIdxSegment != - 1 ) { halts . add ( bushalt ) ; } } return halts ; }
Replies the bus halts on the given segment .