From 4b83875abd8ddd98b5c5b10258fbb9ad3dfdede0 Mon Sep 17 00:00:00 2001 From: hermens Date: Fri, 4 Sep 2009 23:27:14 +0000 Subject: [PATCH] Small fixes for the heapCacheIterator in ReferenceContainerCache: - Start the iteration at startWordHash - When used with rotation, let the iteration stop when the cache is empty git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6293 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../de/anomic/kelondro/text/ReferenceContainerCache.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/de/anomic/kelondro/text/ReferenceContainerCache.java b/source/de/anomic/kelondro/text/ReferenceContainerCache.java index 44d06f3b3..a5072f9ba 100644 --- a/source/de/anomic/kelondro/text/ReferenceContainerCache.java +++ b/source/de/anomic/kelondro/text/ReferenceContainerCache.java @@ -280,6 +280,11 @@ public final class ReferenceContainerCache exte if (startWordHash != null && startWordHash.length == 0) startWordHash = null; this.cachecopy = sortedClone(); this.p = 0; + if (startWordHash != null) { + while ( (this.p < this.cachecopy.length) && + (termOrder.compare(this.cachecopy[this.p].getTermHash(), startWordHash) < 0) + ) this.p++; + } this.latestTermHash = null; // The collection's iterator will return the values in the order that their corresponding keys appear in the tree. } @@ -289,7 +294,7 @@ public final class ReferenceContainerCache exte } public boolean hasNext() { - if (rot) return true; + if (rot) return this.cachecopy.length > 0; return this.p < this.cachecopy.length; } @@ -303,6 +308,7 @@ public final class ReferenceContainerCache exte if (!rot) { return null; } + if (this.cachecopy.length == 0) return null; p = 0; ReferenceContainer c = this.cachecopy[this.p++]; this.latestTermHash = c.getTermHash();