added patch to correct tree-iterator

(symptoms: at the end of the iteration,
more elements are iterated that are not in the
correct order)


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1312 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 25c4e47582
commit c137683a5c

@ -815,8 +815,10 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
Iterator ii;
Node nextNode;
boolean asc;
public correctedNodeIterator(boolean up, boolean rotating, Node start, byte[] firstKey) throws IOException {
asc = up;
ii = new nodeIterator(up, rotating, start);
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
if (nextNode != null) {
@ -837,13 +839,14 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
nextNode = null;
}
public boolean hasNext() {
public boolean hasNext() {
return nextNode != null;
}
}
public Object next() {
Node r = nextNode;
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) nextNode = null; // correct wrong order (this should not happen)
return r;
}

Loading…
Cancel
Save