in commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/PointMap1DImpl.java [233:258]
public boolean hasNext() {
if (lowEntry == null && low != null && low.hasNext()) {
final Entry<Vector1D, V> entry = low.next();
lastLowValue = entry.getKey().getX();
if (entry.getKey().getX() >= lastHighValue) {
// we've crossed over the value returned by the high iterator
low = null;
} else {
lowEntry = DistancedValue.of(entry, refPt.distance(entry.getKey()));
}
}
if (highEntry == null && high != null && high.hasNext()) {
final Entry<Vector1D, V> entry = high.next();
lastHighValue = entry.getKey().getX();
if (entry.getKey().getX() <= lastLowValue) {
// we've crossed over the values returned by the low iterator
high = null;
} else {
highEntry = DistancedValue.of(entry, refPt.distance(entry.getKey()));
}
}
return lowEntry != null || highEntry != null;
}