Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/util/PatternWithStopsSorter.kt
- This file was added.
package it.reyboz.bustorino.util | |||||
import it.reyboz.bustorino.data.gtfs.MatoPatternWithStops | |||||
/** | |||||
* Sorter for the patterns, which takes into account direction and length of pattern | |||||
*/ | |||||
class PatternWithStopsSorter: Comparator<MatoPatternWithStops> { | |||||
override fun compare(p0: MatoPatternWithStops?, p1: MatoPatternWithStops?): Int { | |||||
if (p0 != null && p1!=null) { | |||||
if(p0.pattern.directionId != p1.pattern.directionId){ | |||||
return p0.pattern.directionId - p1.pattern.directionId | |||||
} | |||||
val g = -1*(p0.stopsIndices.size - p1.stopsIndices.size) | |||||
if(g!=0) | |||||
return g; | |||||
else return p0.pattern.code.compareTo(p1.pattern.code) | |||||
} | |||||
else return 0; | |||||
} | |||||
} | |||||
No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register