An iterator to iterate over set bits in an OpenBitSet. this is faster than nextSetBit() for iterating over the complete set of bits, especially when the density of the bits set is high.
Inheritance: Lucene.Net.Search.DocIdSetIterator
Beispiel #1
0
 /// <summary>
 /// Does in-place AND NOT of the bits provided by the
 /// iterator.
 /// </summary>
 public void AndNot(DocIdSetIterator iter)
 {
     if (iter is OpenBitSetIterator && iter.DocID == -1)
     {
         OpenBitSetIterator obs = (OpenBitSetIterator)iter;
         AndNot(obs.arr, obs.words);
         // advance after last doc that would be accepted if standard
         // iteration is used (to exhaust it):
         obs.Advance(numBits);
     }
     else if (iter is FixedBitSetIterator && iter.DocID == -1)
     {
         FixedBitSetIterator fbs = (FixedBitSetIterator)iter;
         AndNot(fbs.bits, fbs.numWords);
         // advance after last doc that would be accepted if standard
         // iteration is used (to exhaust it):
         fbs.Advance(numBits);
     }
     else
     {
         int doc;
         while ((doc = iter.NextDoc()) < numBits)
         {
             Clear(doc);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Does in-place OR of the bits provided by the
 ///  iterator.
 /// </summary>
 public void Or(DocIdSetIterator iter)
 {
     if (iter is OpenBitSetIterator && iter.DocID() == -1)
     {
         OpenBitSetIterator obs = (OpenBitSetIterator)iter;
         Or(obs.Arr, obs.Words);
         // advance after last doc that would be accepted if standard
         // iteration is used (to exhaust it):
         obs.Advance(NumBits);
     }
     else if (iter is FixedBitSetIterator && iter.DocID() == -1)
     {
         FixedBitSetIterator fbs = (FixedBitSetIterator)iter;
         Or(fbs.bits, fbs.NumWords);
         // advance after last doc that would be accepted if standard
         // iteration is used (to exhaust it):
         fbs.Advance(NumBits);
     }
     else
     {
         int doc;
         while ((doc = iter.NextDoc()) < NumBits)
         {
             Set(doc);
         }
     }
 }
Beispiel #3
0
        internal virtual void  DoIterate2(System.Collections.BitArray a, OpenBitSet b)
        {
            int aa = -1, bb = -1;
            OpenBitSetIterator iterator = new OpenBitSetIterator(b);

            do
            {
                aa = BitSetSupport.NextSetBit(a, aa + 1);
                bb = rand.NextDouble() > 0.5 ? iterator.NextDoc(null) : iterator.Advance(bb + 1, null);
                Assert.AreEqual(aa == -1?DocIdSetIterator.NO_MORE_DOCS:aa, bb);
            }while (aa >= 0);
        }
        internal virtual void DoIterate2(BitArray a, OpenBitSet b)
        {
            int aa = -1, bb = -1;
            OpenBitSetIterator iterator = new OpenBitSetIterator(b);

            do
            {
                aa = a.NextSetBit(aa + 1);
                bb = Random().NextBoolean() ? iterator.NextDoc() : iterator.Advance(bb + 1);
                Assert.AreEqual(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
            } while (aa >= 0);
        }
Beispiel #5
0
		internal virtual void  DoIterate2(System.Collections.BitArray a, OpenBitSet b)
		{
			int aa = - 1, bb = - 1;
			OpenBitSetIterator iterator = new OpenBitSetIterator(b);
			do 
			{
				aa = SupportClass.BitSetSupport.NextSetBit(a, aa + 1);
				bb = rand.NextDouble() > 0.5 ? iterator.NextDoc() : iterator.Advance(bb + 1);
				Assert.AreEqual(aa == - 1?DocIdSetIterator.NO_MORE_DOCS:aa, bb);
			}
			while (aa >= 0);
		}
Beispiel #6
0
 /// <summary>
 /// Does in-place AND of the bits provided by the
 /// iterator.
 /// </summary>
 public void And(DocIdSetIterator iter)
 {
     if (iter is OpenBitSetIterator && iter.DocID == -1)
     {
         OpenBitSetIterator obs = (OpenBitSetIterator)iter;
         And(obs.arr, obs.words);
         // advance after last doc that would be accepted if standard
         // iteration is used (to exhaust it):
         obs.Advance(numBits);
     }
     else if (iter is FixedBitSetIterator && iter.DocID == -1)
     {
         FixedBitSetIterator fbs = (FixedBitSetIterator)iter;
         And(fbs.bits, fbs.numWords);
         // advance after last doc that would be accepted if standard
         // iteration is used (to exhaust it):
         fbs.Advance(numBits);
     }
     else
     {
         if (numBits == 0)
         {
             return;
         }
         int disiDoc, bitSetDoc = NextSetBit(0);
         while (bitSetDoc != -1 && (disiDoc = iter.Advance(bitSetDoc)) < numBits)
         {
             Clear(bitSetDoc, disiDoc);
             disiDoc++;
             bitSetDoc = (disiDoc < numBits) ? NextSetBit(disiDoc) : -1;
         }
         if (bitSetDoc != -1)
         {
             Clear(bitSetDoc, numBits);
         }
     }
 }