Individual indexed bits can be examined, set, or cleared. Subranges can quickly be extracted, copied and replaced. Quick iteration over subranges is provided by optimized internal iterators (forEach() methods). One BitVector
may be used to modify the contents of another BitVector
through logical AND, OR, XOR and other similar operations.
All operations consider the bits 0..size()-1 and nothing else. Operations involving two bitvectors (like AND, OR, XOR, etc.) will throw an IllegalArgumentException if the secondary bit vector has a size smaller than the receiver.
A BitVector is never automatically resized, but it can manually be grown or shrinked via setSize(...).
For use cases that need to store several bits per information entity, quick accessors are provided that interpret subranges as 64 bit long integers.
Why this class? Fist, boolean[] take one byte per stored bit. This class takes one bit per stored bit. Second, many applications find the semantics of java.util.BitSet not particularly helpful for their needs. Third, operations working on all bits of a bitvector are extremely quick. For example, on NT, Pentium Pro 200 Mhz, SunJDK1.2.2, java -classic, for two bitvectors A,B (both much larger than processor cache), the following results are obtained.
Note that this implementation is not synchronized. @author wolfgang.hoschek@cern.ch @version 1.01, 11/10/99 @see QuickBitVector @see BitMatrix @see java.util.BitSet
width
bits which are stored as 64bit "words" (long
s). In this context a register is at most 64bits.
@author rgrzywinski
All bit operations are present in two forms: a normal form and a self form. The normal form returns a newly created object containing the result, while the self form puts the result in the calling object (this). The return value of the self form is the calling object itself. This is done to allow easier manipulation of the results, making it possible to chain operations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|