Skip to content

Commit 2625a02

Browse files
author
Peter
committed
simplified BaseGraph.EdgeIterable.next() method
1 parent 8533f02 commit 2625a02

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

core/src/main/java/com/graphhopper/storage/BaseGraph.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.graphhopper.routing.util.EdgeFilter;
2626
import com.graphhopper.routing.util.EncodingManager;
2727
import com.graphhopper.search.NameIndex;
28+
import static com.graphhopper.storage.Test.NO_EDGE;
2829
import com.graphhopper.util.*;
2930
import static com.graphhopper.util.Helper.nf;
3031
import com.graphhopper.util.shapes.BBox;
@@ -566,6 +567,30 @@ protected void selectEdgeAccess()
566567

567568
@Override
568569
public final boolean next()
570+
{
571+
for (;;)
572+
{
573+
if (nextEdgeId == EdgeIterator.NO_EDGE)
574+
return false;
575+
576+
selectEdgeAccess();
577+
edgePointer = edgeAccess.toPointer(nextEdgeId);
578+
edgeId = nextEdgeId;
579+
adjNode = edgeAccess.getOtherNode(baseNode, edgePointer);
580+
reverse = baseNode > adjNode;
581+
freshFlags = false;
582+
583+
// position to next edge
584+
nextEdgeId = edgeAccess.edges.getInt(edgeAccess.getLinkPosInEdgeArea(baseNode, adjNode, edgePointer));
585+
assert nextEdgeId == edgeId : ("endless loop detected for base node: " + baseNode + ", adj node: " + adjNode
586+
+ ", edge pointer: " + edgePointer + ", edge: " + edgeId);
587+
588+
if (filter.accept(this))
589+
return true;
590+
}
591+
}
592+
593+
public final boolean next_debug()
569594
{
570595
int i = 0;
571596
boolean foundNext = false;

0 commit comments

Comments
 (0)