public long next(){
  long result=-1l;
  if (cache < 0L && bufferElements > 0) {
    result=getNextFromBuffer();
    bufferElements--;
  }
 else {
    result=cache;
    cache=-1L;
  }
  if (!cs.isEmpty()) {
    long first=cs.first();
    if (result > first || result == -1L) {
      cs.remove(first);
      cache=result;
      result=first;
    }
  }
  if (result == -1L) {
    throw new NoSuchElementException();
  }
  Assert.check(previous < result,EC.GENERAL);
  previous=result;
  readElements++;
  return result;
}

public long next ( ) { long result = - 1l ; if ( cache < 0L && bufferElements > 0 ) { result = getNextFromBuffer ( ) ; bufferElements -- ; } else { result = cache ; cache = - 1L ; } if ( ! cs . isEmpty ( ) ) { long first = cs . first ( ) ; if ( result > first || result == - 1L ) { cs . remove ( first ) ; cache = result ; result = first ; } } if ( result == - 1L ) { throw new NoSuchElementException ( ) ; } Assert . check ( previous < result , EC . GENERAL ) ; previous = result ; readElements ++ ; return result ; }
returns the next element in the iteration .
