Hey
Infinispan's implementations of QueryIterator don't conform to the
contract of ListIterator and are pretty buggy (see
https://issues.jboss.org/browse/ISPN-2337). The most important bug is
the fact that calling next() and then previous() should return the same
element, but it doesn't.
I'm trying to fix the bugs, but have now realized that even the
interface QueryIterator is problematic.
1. QueryIterator.first()
This one isn't as problematic as the next ones, but it's strange that
calling first() and then next() returns the first element of the
collection. It would be clearer if the method were called
"beforeFirst()" or something similar.
2. QueryIterator.last()
What should the iterator return when you call last() and then call
next()? What about if you call last() and then previous()? A user would
probably call last() as the first step of iterating over the results
backwards. So calling previous() should return the last element. The
method should probably be renamed to "afterLast()".
3. QueryIterator.afterFirst() & beforeLast()
These two are OK. Calling next() after afterFirst() should return the
second element, while calling previous() should return the first element.
4. isFirst(), isLast()
ListIterator does not have the concept of "current element", but the
javadoc of all the is*() methods talk about the current element, which
is ambiguous. Therefore isFirst() and isLast() should probably be
renamed to isBeforeFirst() and isAfterLast().
5. jumpToResult(int index)
When jumping to index=1, what does next() return? What about previous()?
We should probably replace the method with two others: beforeResult(int
index) and afterResult(int index)
Any comments / other ideas?
Marko