
org.opentripplanner.astar.strategy.MaxCountSkipEdgeStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
The newest version!
package org.opentripplanner.astar.strategy;
import java.util.function.Predicate;
import org.opentripplanner.astar.spi.AStarEdge;
import org.opentripplanner.astar.spi.AStarState;
import org.opentripplanner.astar.spi.SkipEdgeStrategy;
/**
* Skips edges when the specified number of desired vertices have been visited.
*/
public class MaxCountSkipEdgeStrategy<
State extends AStarState, Edge extends AStarEdge
>
implements SkipEdgeStrategy {
private final int maxCount;
private final Predicate shouldIncreaseCount;
private int visited;
public MaxCountSkipEdgeStrategy(int count, Predicate shouldIncreaseCount) {
this.maxCount = count;
this.shouldIncreaseCount = shouldIncreaseCount;
this.visited = 0;
}
@Override
public boolean shouldSkipEdge(State current, Edge edge) {
if (shouldIncreaseCount.test(current)) {
visited++;
}
return visited > maxCount;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy