Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
(no rotation)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1313 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jan 12, 2006
1 parent c137683 commit 45c44ca
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions source/de/anomic/kelondro/kelondroTree.java
Expand Up @@ -815,20 +815,29 @@ private class correctedNodeIterator implements Iterator {

Iterator ii;
Node nextNode;
boolean asc;
boolean asc, rot;
Node start;
byte[] firstKey;

public correctedNodeIterator(boolean up, boolean rotating, Node start, byte[] firstKey) throws IOException {
asc = up;
ii = new nodeIterator(up, rotating, start);
rot = rotating;
this.start = start;
this.firstKey = firstKey;
init();
}

private void init() throws IOException {
ii = new nodeIterator(asc, rot, start);
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
if (nextNode != null) {
int c = objectOrder.compare(firstKey, nextNode.getKey());
if ((c > 0) && (up)) {
if ((c > 0) && (asc)) {
// firstKey > nextNode.getKey()
logWarning("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey()));
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
}
if ((c < 0) && (!(up))) {
if ((c < 0) && (!(asc))) {
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
}
}
Expand All @@ -846,7 +855,18 @@ public boolean hasNext() {
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)
if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) {
// correct wrong order (this should not happen)
if (rot) {
try {
init();
} catch (IOException e) {
nextNode = null;
}
} else {
nextNode = null;
}
}
return r;
}

Expand Down

0 comments on commit 45c44ca

Please sign in to comment.