org.apache.lucene.util
Class FixedBitSet

java.lang.Object
  extended by org.apache.lucene.search.DocIdSet
      extended by org.apache.lucene.util.FixedBitSet

public final class FixedBitSet
extends DocIdSet

BitSet of fixed length (numBits), backed by accessible (getBits()) long[], accessed with an int index, implementing Bits and DocIdSet. Unlike OpenBitSet this bit set does not auto-expand, cannot handle long index, and does not have fastXX/XX variants (just X).

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

Field Summary
 
Fields inherited from class org.apache.lucene.search.DocIdSet
EMPTY_DOCIDSET
 
Constructor Summary
FixedBitSet(FixedBitSet other)
          Makes full copy.
FixedBitSet(int numBits)
           
 
Method Summary
static int bits2words(int numBits)
          returns the number of 64 bit words it would take to hold numBits
 int cardinality()
          Returns number of set bits.
 void clear(int index)
           
 void clear(int startIndex, int endIndex)
          Clears a range of bits.
 Object clone()
           
 boolean equals(Object o)
          returns true if both sets have the same bits set
 void flip(int startIndex, int endIndex)
          Flips a range of bits
 boolean get(int index)
           
 boolean getAndClear(int index)
           
 boolean getAndSet(int index)
           
 long[] getBits()
          Expert.
 int hashCode()
           
 boolean isCacheable()
          This DocIdSet implementation is cacheable.
 DocIdSetIterator iterator()
          Provides a DocIdSetIterator to access the set.
 int length()
           
 int nextSetBit(int index)
          Returns the index of the first set bit starting at the index specified.
 void or(DocIdSetIterator iter)
          Does in-place OR of the bits provided by the iterator.
 void or(FixedBitSet other)
           
 int prevSetBit(int index)
           
 void set(int index)
           
 void set(int startIndex, int endIndex)
          Sets a range of bits
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedBitSet

public FixedBitSet(int numBits)

FixedBitSet

public FixedBitSet(FixedBitSet other)
Makes full copy.

Method Detail

bits2words

public static int bits2words(int numBits)
returns the number of 64 bit words it would take to hold numBits


iterator

public DocIdSetIterator iterator()
Description copied from class: DocIdSet
Provides a DocIdSetIterator to access the set. This implementation can return null or DocIdSet.EMPTY_DOCIDSET.iterator() if there are no docs that match.

Specified by:
iterator in class DocIdSet

length

public int length()

isCacheable

public boolean isCacheable()
This DocIdSet implementation is cacheable.

Overrides:
isCacheable in class DocIdSet

getBits

public long[] getBits()
Expert.


cardinality

public int cardinality()
Returns number of set bits. NOTE: this visits every long in the backing bits array, and the result is not internally cached!


get

public boolean get(int index)

set

public void set(int index)

getAndSet

public boolean getAndSet(int index)

clear

public void clear(int index)

getAndClear

public boolean getAndClear(int index)

nextSetBit

public int nextSetBit(int index)
Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.


prevSetBit

public int prevSetBit(int index)

or

public void or(DocIdSetIterator iter)
        throws IOException
Does in-place OR of the bits provided by the iterator.

Throws:
IOException

or

public void or(FixedBitSet other)

flip

public void flip(int startIndex,
                 int endIndex)
Flips a range of bits

Parameters:
startIndex - lower index
endIndex - one-past the last bit to flip

set

public void set(int startIndex,
                int endIndex)
Sets a range of bits

Parameters:
startIndex - lower index
endIndex - one-past the last bit to set

clear

public void clear(int startIndex,
                  int endIndex)
Clears a range of bits.

Parameters:
startIndex - lower index
endIndex - one-past the last bit to clear

clone

public Object clone()
Overrides:
clone in class Object

equals

public boolean equals(Object o)
returns true if both sets have the same bits set

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.