DoubleObjectIterator( ConcurrentDoubleOrderedListMap map, double lo, double hi, boolean loIncl, boolean hiIncl) { low = lo; high = hi; orderedMap = map; lowInclusive = loIncl; highInclusive = hiIncl; if (low == Double.MIN_VALUE) { current = orderedMap.safeNext(orderedMap.head); } else { current = orderedMap.ceilingNode(low); } pos = 0; if (current == null) { len = 0; } else { pos = findBeginIndex(current, low, lowInclusive); len = findEndIndex(current, high, highInclusive) + 1; } }
public boolean hasNext() { if (pos < len) { return true; } else { assert pos == len; if (current == null) return false; Node next = orderedMap.safeNext(current); orderedMap.release(current); current = next; pos = 0; if (current == null) { return false; } len = findEndIndex(current, high, highInclusive) + 1; if (len == 0) { orderedMap.release(current); current = null; return false; } return true; } }