public class RankedBitVectorImpl extends Object implements RankedBitVector, Iterable<Boolean>
RankedBitVector
. This implementation uses
auxiliary classes to have efficient performance for the methods of a ranked
bit vector. Hence, countBits(boolean, long)
uses an instance of
CountBitsArray
and findPosition(boolean, long)
uses two
instances of FindPositionArray
.CountBitsArray
,
FindPositionArray
NOT_FOUND
Constructor and Description |
---|
RankedBitVectorImpl()
Constructor of a ranked bit vector of size 0.
|
RankedBitVectorImpl(BitVector bitVector)
Copy constructor of a ranked bit vector.
|
RankedBitVectorImpl(long initialSize)
Constructor of a ranked bit vector of size initialSize.
|
RankedBitVectorImpl(long initialSize,
int countBlockSize,
int findPositionBlockSize)
Constructor of a ranked bit vector of size initialSize and block
size blockSize.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addBit(boolean bit)
Appends a bit to this bit vector.
|
long |
countBits(boolean bit,
long position)
This is the "rank" method of bit vectors.
|
boolean |
equals(Object obj)
Returns
true if and only if the specified object is also a
BitVector and both contain the same bits in the same order. |
long |
findPosition(boolean bit,
long nOccurrence)
This is the "select" method of bit vectors.
|
boolean |
getBit(long position)
This is the "access" method of bit vectors.
|
int |
hashCode() |
Iterator<Boolean> |
iterator() |
void |
setBit(long position,
boolean bit)
Sets a bit at a particular position.
|
long |
size() |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public RankedBitVectorImpl()
public RankedBitVectorImpl(BitVector bitVector)
bitVector
- bit vectorpublic RankedBitVectorImpl(long initialSize)
false
at all indexes.initialSize
- initial size of this ranked bit vectorpublic RankedBitVectorImpl(long initialSize, int countBlockSize, int findPositionBlockSize)
false
at all
indexes.initialSize
- initial size of this ranked bit vectorcountBlockSize
- block size to count number of occurrences of a value; this
value must be a positive numberfindPositionBlockSize
- block size to find the position of the n-th occurrence
of a value; this value must be greater than or equal to 64IllegalArgumentException
- if any of the block sizes is too smallpublic boolean addBit(boolean bit)
BitVector
public long countBits(boolean bit, long position)
RankedBitVector
countBits
in interface RankedBitVector
bit
- bitposition
- positionpublic boolean equals(Object obj)
BitVector
true
if and only if the specified object is also a
BitVector and both contain the same bits in the same order.public long findPosition(boolean bit, long nOccurrence)
RankedBitVector
findPosition
in interface RankedBitVector
bit
- bitnOccurrence
- number of occurrencespublic boolean getBit(long position)
BitVector
public void setBit(long position, boolean bit)
BitVector
Copyright © 2014–2024 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage