| | |
| | | int total = path.size(); |
| | | List<Integer> segmentEndIndices = new ArrayList<>(); |
| | | if (liftTransferPath != null) { |
| | | int searchStartIdx = 0; |
| | | for (Integer liftTransferStationId : liftTransferPath) { |
| | | int endIndex = path.indexOf(liftTransferStationId); |
| | | int endIndex = findNextStationIndex(path, liftTransferStationId, searchStartIdx); |
| | | if (endIndex >= 0) { |
| | | searchStartIdx = endIndex + 1; |
| | | } |
| | | if (endIndex <= 0) { |
| | | continue; |
| | | } |
| | |
| | | return plan; |
| | | } |
| | | |
| | | private int findNextStationIndex(List<Integer> path, Integer stationId, int fromIndex) { |
| | | if (path == null || path.isEmpty() || stationId == null) { |
| | | return -1; |
| | | } |
| | | int startIdx = Math.max(fromIndex, 0); |
| | | for (int i = startIdx; i < path.size(); i++) { |
| | | if (stationId.equals(path.get(i))) { |
| | | return i; |
| | | } |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | private List<Integer> copyIntegerList(List<Integer> source) { |
| | | if (source == null) { |
| | | return new ArrayList<>(); |