Package it.unimi.dsi.bits
Class BitVectors
java.lang.Object
it.unimi.dsi.bits.BitVectors
public class BitVectors extends Object
A class providing static methods and objects that do useful things with bit vectors.
- See Also:
BitVector
-
Field Summary
Fields Modifier and Type Field Description static BitVectorEMPTY_VECTORAn immutable, singleton empty bit vector.static it.unimi.dsi.bits.BitVectors.BitVectorOfflineSerializerOFFLINE_SERIALIZERA serializer forLongArrayBitVectorinstances that can be used withOfflineIterable.static BitVectorONEAn immutable bit vector of length one containing a one.static BitVectorZEROAn immutable bit vector of length one containing a zero. -
Method Summary
Modifier and Type Method Description static voidensureFromTo(long bitVectorLength, long from, long to)static <T extends BitVector>
TransformationStrategy<T>identity()Deprecated.static LongArrayBitVectorreadFast(DataInput dis)Reads quickly a bit vector from aDataInputStream.static LongArrayBitVectorreadFast(DataInput dis, LongArrayBitVector bv)Reads quickly a bit vector from aDataInputStream.static voidwriteFast(BitVector v, DataOutput dos)Writes quickly a bit vector to aDataOutputStream.
-
Field Details
-
EMPTY_VECTOR
An immutable, singleton empty bit vector. -
ZERO
An immutable bit vector of length one containing a zero. -
ONE
An immutable bit vector of length one containing a one. -
OFFLINE_SERIALIZER
public static it.unimi.dsi.bits.BitVectors.BitVectorOfflineSerializer OFFLINE_SERIALIZERA serializer forLongArrayBitVectorinstances that can be used withOfflineIterable. It can serialize any implementation ofBitVector, and requires at construction time an instance ofLongArrayBitVectorthat will be used to return deserialized elements.
-
-
Method Details
-
identity
Deprecated. -
ensureFromTo
public static void ensureFromTo(long bitVectorLength, long from, long to) -
writeFast
Writes quickly a bit vector to aDataOutputStream.This method writes a bit vector in a simple format: first, a long representing the length. Then, as many longs as necessary to write the bits in the bit vectors (i.e.,
LongArrayBitVector.numWords(long)of the bit vector length), obtained viaBitVector.getLong(long, long).The main purpose of this function is to support
OfflineIterable(seeOFFLINE_SERIALIZER).- Parameters:
v- a bit vector.dos- a data output stream.- Throws:
IOException
-
readFast
Reads quickly a bit vector from aDataInputStream.This method is the dual of
writeFast(BitVector, DataOutput). If you need to avoid creating a bit vector at each call, please have a look atreadFast(DataInput, LongArrayBitVector).- Parameters:
dis- a data input stream.- Returns:
- the next bit vector in the stream, as saved by
writeFast(BitVector, DataOutput). - Throws:
IOException- See Also:
writeFast(BitVector, DataOutput),readFast(DataInput, LongArrayBitVector)
-
readFast
Reads quickly a bit vector from aDataInputStream.This method is similar in purpose to
readFast(DataInput), but it allows reuse of the bit vector.- Parameters:
dis- a data input stream.bv- a long-array bit vector.- Returns:
bv, filled with the next bit vector in the stream, as saved bywriteFast(BitVector, DataOutput).- Throws:
IOException- See Also:
writeFast(BitVector, DataOutput),readFast(DataInput)
-