Class BitVectorImpl
java.lang.Object
org.wikidata.wdtk.storage.datastructures.BitVectorImpl
Default implementation of
BitVector
. This implementation contains an
array of long, and each long stores 64 bits. When more space is
needed, the internal array grows exponentially. This bit vector is
flexible, which means that:
- it is always possible to store a bit in any non-negative position without explicitly resizing the vector,
- any non-negative position outside the bit vector can be retrieved and
contains a
false
.
- Author:
- Julian Mendez
-
Constructor Summary
ConstructorDescriptionConstructor of a bit vector of size 0.BitVectorImpl
(long initialSize) Constructor of a bit vector of size initialSize.BitVectorImpl
(BitVector bitVector) Copy constructor of a bit vector. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addBit
(boolean bit) Appends a bit to this bit vector.boolean
Returnstrue
if and only if the specified object is also a BitVector and both contain the same bits in the same order.boolean
getBit
(long position) This is the "access" method of bit vectors.int
hashCode()
iterator()
void
setBit
(long position, boolean bit) Sets a bit at a particular position.long
size()
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BitVectorImpl
public BitVectorImpl()Constructor of a bit vector of size 0. -
BitVectorImpl
Copy constructor of a bit vector.- Parameters:
bitVector
- bit vector
-
BitVectorImpl
public BitVectorImpl(long initialSize) Constructor of a bit vector of size initialSize. The bit vector containsfalse
at all indexes.- Parameters:
initialSize
- initial size of this bit vector
-
-
Method Details
-
addBit
public boolean addBit(boolean bit) Description copied from interface:BitVector
Appends a bit to this bit vector. -
equals
Description copied from interface:BitVector
Returnstrue
if and only if the specified object is also a BitVector and both contain the same bits in the same order. -
getBit
public boolean getBit(long position) Description copied from interface:BitVector
This is the "access" method of bit vectors. -
hashCode
public int hashCode() -
iterator
-
setBit
public void setBit(long position, boolean bit) Description copied from interface:BitVector
Sets a bit at a particular position. -
size
public long size() -
toString
-