-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5249 from opentripplanner/pass-through_raptor-cha…
…nges Pass through raptor changes
- Loading branch information
Showing
91 changed files
with
3,009 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/org/opentripplanner/framework/lang/IntBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.opentripplanner.framework.lang; | ||
|
||
/** | ||
* An IntBox is a writable container for an int. The most common use-case for this class is to | ||
* be able to set an integer value inside a lambda callback where local variables is not | ||
* accessible. | ||
*/ | ||
public final class IntBox { | ||
|
||
private int value; | ||
|
||
public IntBox(int value) { | ||
this.value = value; | ||
} | ||
|
||
public int get() { | ||
return value; | ||
} | ||
|
||
public void set(int value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || o.getClass() != IntBox.class) { | ||
return false; | ||
} | ||
return value == ((IntBox) o).value; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Integer.hashCode(value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Integer.toString(value); | ||
} | ||
|
||
public void inc() { | ||
++value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.opentripplanner.raptor.api.request; | ||
|
||
import java.util.Arrays; | ||
import java.util.BitSet; | ||
import java.util.Objects; | ||
import java.util.stream.IntStream; | ||
|
||
/** | ||
* A collection of stop indexes used to define a pass through-point. | ||
*/ | ||
public class PassThroughPoint { | ||
|
||
private final int[] stops; | ||
|
||
public PassThroughPoint(int[] stops) { | ||
Objects.requireNonNull(stops); | ||
if (stops.length == 0) { | ||
throw new IllegalArgumentException("At least one stop is required"); | ||
} | ||
this.stops = Arrays.copyOf(stops, stops.length); | ||
} | ||
|
||
/** | ||
* This is a convenient accessor method used inside Raptor. It converts the list stops to a | ||
* bit-set. Add other access methods if needed. | ||
*/ | ||
public BitSet asBitSet() { | ||
return IntStream.of(stops).collect(BitSet::new, BitSet::set, BitSet::or); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PassThroughPoint that = (PassThroughPoint) o; | ||
return Arrays.equals(stops, that.stops); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Arrays.hashCode(stops); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(stops: " + Arrays.toString(stops) + ")"; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.opentripplanner.raptor.api.request; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Stream; | ||
import org.opentripplanner.framework.tostring.ToStringBuilder; | ||
|
||
/** | ||
* An ordered set of pass through points. | ||
*/ | ||
public class PassThroughPoints { | ||
|
||
private final List<PassThroughPoint> points; | ||
|
||
public PassThroughPoints(List<PassThroughPoint> points) { | ||
this.points = List.copyOf(Objects.requireNonNull(points)); | ||
} | ||
|
||
public Stream<PassThroughPoint> stream() { | ||
return points.stream(); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return points.isEmpty(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PassThroughPoints that = (PassThroughPoints) o; | ||
return Objects.equals(points, that.points); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(points); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.of(PassThroughPoints.class).addCol("points", points).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.