From 2a7b13bd8fd6b2da53267df2e1964846e6261435 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Tue, 5 Sep 2006 15:23:18 +0000 Subject: [PATCH] BitSetIterator.next(int startFrom) public, add test git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@440369 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/solr/util/BitSetIterator.java | 2 +- src/test/org/apache/solr/util/TestOpenBitSet.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/solr/util/BitSetIterator.java b/src/java/org/apache/solr/util/BitSetIterator.java index e91bc8f5a4a..75d67add8b2 100644 --- a/src/java/org/apache/solr/util/BitSetIterator.java +++ b/src/java/org/apache/solr/util/BitSetIterator.java @@ -108,7 +108,7 @@ public class BitSetIterator { return (i<<6) + bitIndex; } - int next(int fromIndex) { + public int next(int fromIndex) { indexArray=0; i = fromIndex >> 6; if (i>=words) { diff --git a/src/test/org/apache/solr/util/TestOpenBitSet.java b/src/test/org/apache/solr/util/TestOpenBitSet.java index 1ac5db96bd5..b9c6a518315 100644 --- a/src/test/org/apache/solr/util/TestOpenBitSet.java +++ b/src/test/org/apache/solr/util/TestOpenBitSet.java @@ -30,12 +30,16 @@ public class TestOpenBitSet extends TestCase { } while (aa>=0); } + // test interleaving different BitSetIterator.next() void doIterate(BitSet a, OpenBitSet b) { int aa=-1,bb=-1; BitSetIterator iterator = new BitSetIterator(b); do { aa = a.nextSetBit(aa+1); - bb = iterator.next(); + if (rand.nextBoolean()) + bb = iterator.next(); + else + bb = iterator.next(bb+1); assertEquals(aa,bb); } while (aa>=0); }