use of com.carrotsearch.hppc.IntArrayDeque in project graphhopper by graphhopper.
the class DepthFirstSearch method start.
/**
* beginning with startNode add all following nodes to LIFO queue. If node has been already
* explored before, skip reexploration.
*/
@Override
public void start(EdgeExplorer explorer, int startNode) {
IntArrayDeque stack = new IntArrayDeque();
GHBitSet explored = createBitSet();
stack.addLast(startNode);
int current;
while (stack.size() > 0) {
current = stack.removeLast();
if (!explored.contains(current) && goFurther(current)) {
EdgeIterator iter = explorer.setBaseNode(current);
while (iter.next()) {
int connectedId = iter.getAdjNode();
if (checkAdjacent(iter)) {
stack.addLast(connectedId);
}
}
explored.add(current);
}
}
}
Aggregations