Java Iterator implementation - next() and hasNext() enforcing order
concurrency, iterator, java
Solution
I might be missing something here, but why not call `hasNext()` internally in your implementation?
Problem
I have an implementation of `java.util.Iterator` which requires that the call to `next()` should always be proceeded by a call to `hasNext()`. (This is because results are returned asynchronosly in a multi threaded environment and it is never clear how many more results there might be). Would it be 'correct' to properly document this in the JavaDoc and then throw a `RuntimeException` if this was violated. Or is this stretching the Iterator interface a little too far? All thoughts appreciated?