Code example for BitSet

0
import org.apache.lucene.search.DocIdSetIterator; 
 
public class BitsetDocSet extends DocIdSet { 
	private final BitSet _bs;
	public BitsetDocSet() { 
		_bs=new BitSet();
	} 
	 
	public BitsetDocSet(int nbits) {
		_bs=new BitSet(nbits);
	} 
 
	public void addDoc(int docid) {
		_bs.set(docid);
	} 
 
	public int size() { 
		return _bs.cardinality();
	} 
 
	@Override