docs: @Pure
  	public double getDistanceBetweenBusHalts(int firsthaltIndex, int lasthaltIndex) {
  		if (firsthaltIndex < 0 || firsthaltIndex >= this.validHalts.size() - 1) {
  			throw new ArrayIndexOutOfBoundsException(firsthaltIndex);
  		}
  		if (lasthaltIndex <= firsthaltIndex || lasthaltIndex >= this.validHalts.size()) {
  			throw new ArrayIndexOutOfBoundsException(lasthaltIndex);
  		}
  
  		double length = 0;
  
  		final BusItineraryHalt b1 = this.validHalts.get(firsthaltIndex);
  		final BusItineraryHalt b2 = this.validHalts.get(lasthaltIndex);
  		final int firstSegment = b1.getRoadSegmentIndex();
  		final int lastSegment = b2.getRoadSegmentIndex();
  
  		for (int i = firstSegment + 1; i < lastSegment; ++i) {
  			final RoadSegment segment = this.roadSegments.getRoadSegmentAt(i);
  			length += segment.getLength();
  		}
  
  		Direction1D direction = getRoadSegmentDirection(firstSegment);
  		if (direction.isRevertedSegmentDirection()) {
  			length += b1.getPositionOnSegment();
  		} else {
  			length += this.roadSegments.getRoadSegmentAt(firstSegment).getLength() - b1.getPositionOnSegment();
  		}
  
  		direction = getRoadSegmentDirection(lastSegment);
  		if (direction.isSegmentDirection()) {
  			length += b2.getPositionOnSegment();
  		} else {
  			length += this.roadSegments.getRoadSegmentAt(firstSegment).getLength() - b2.getPositionOnSegment();
  		}
  
  		return length;
  	}