An "open" BitSet implementation that allows direct access to the array of words storing the bits.

Unlike java.util.bitset, the fact that bits are packed into an array of longs is part of the interface. This allows efficient implementation of other algorithms by someone other than the author. It also allows one to efficiently implement alternate serialization or interchange formats.

CopyC#
OpenBitSet
is faster than
CopyC#
java.util.BitSet
in most operations and *much* faster at calculating cardinality of sets and results of set operations. It can also handle sets of larger cardinality (up to 64 * 2**32-1)

The goals of

CopyC#
OpenBitSet
are the fastest implementation possible, and maximum code reuse. Extra safety and encapsulation may always be built on top, but if that's built in, the cost can never be removed (and hence people re-implement their own version in order to get better performance). If you want a "safe", totally encapsulated (and slower and limited) BitSet class, use
CopyC#
java.util.BitSet
.

Performance Results

Test system: Pentium 4, Sun Java 1.5_06 -server -Xbatch -Xmx64M
BitSet size = 1,000,000
Results are java.util.BitSet time divided by OpenBitSet time.
cardinalityintersect_countunionnextSetBitgetiterator
50% full3.363.961.441.461.991.58
1% full3.313.90 1.04 0.99

Test system: AMD Opteron, 64 bit linux, Sun Java 1.5_06 -server -Xbatch -Xmx64M
BitSet size = 1,000,000
Results are java.util.BitSet time divided by OpenBitSet time.
cardinalityintersect_countunionnextSetBitgetiterator
50% full2.503.501.001.031.121.25
1% full2.513.49 1.00 1.02

Namespace: Lucene.Net.Util
Assembly: Lucene.Net (in Lucene.Net.dll) Version: 2.9.4.1

Syntax

C#
[SerializableAttribute]
public class OpenBitSet : DocIdSet, ICloneable
Visual Basic
<SerializableAttribute> _
Public Class OpenBitSet _
	Inherits DocIdSet _
	Implements ICloneable
Visual C++
[SerializableAttribute]
public ref class OpenBitSet : public DocIdSet, 
	ICloneable

Inheritance Hierarchy

See Also