|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.bits.BitVectors
public class BitVectors
A class providing static methods and objects that do useful things with bit vectors.
BitVector
Nested Class Summary | |
---|---|
static class |
BitVectors.OfflineBitVectorIterable
|
protected static class |
BitVectors.OfflineBitVectorIterator
|
Field Summary | |
---|---|
static BitVector |
EMPTY_VECTOR
An immutable, singleton empty bit vector. |
static BitVector |
ONE
An immutable bit vector of length one containing a one. |
static BitVector |
ZERO
An immutable bit vector of length one containing a zero. |
Method Summary | ||
---|---|---|
static void |
ensureFromTo(long bitVectorLength,
long from,
long to)
|
|
static
|
identity()
Deprecated. |
|
static BitVectors.OfflineBitVectorIterable |
makeOffline(java.util.Iterator<? extends BitVector> iterator)
Makes an iterable object containing bit vectors offline. |
|
static LongArrayBitVector |
readFast(java.io.DataInputStream dis)
Reads quickly a bit vector from a DataInputStream . |
|
static LongArrayBitVector |
readFast(java.io.DataInputStream dis,
LongArrayBitVector bv)
Reads quickly a bit vector from a DataInputStream . |
|
static void |
writeFast(BitVector v,
java.io.DataOutputStream dos)
Writes quickly a bit vector to a DataOutputStream . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final BitVector EMPTY_VECTOR
public static final BitVector ZERO
public static final BitVector ONE
Method Detail |
---|
@Deprecated public static <T extends BitVector> TransformationStrategy<T> identity()
public static void ensureFromTo(long bitVectorLength, long from, long to)
public static void writeFast(BitVector v, java.io.DataOutputStream dos) throws java.io.IOException
DataOutputStream
.
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 via BitVector.getLong(long, long)
.
The main purpose of this function is to support makeOffline(Iterator)
and similar methods.
v
- a bit vector.dos
- a data output stream.
java.io.IOException
public static LongArrayBitVector readFast(java.io.DataInputStream dis) throws java.io.IOException
DataInputStream
.
This method is the dual of writeFast(BitVector, DataOutputStream)
. If you
need to avoid creating a bit vector at each call, please have a look at readFast(DataInputStream, LongArrayBitVector)
.
dis
- a data input stream.
writeFast(BitVector, DataOutputStream)
.
java.io.IOException
writeFast(BitVector, DataOutputStream)
,
readFast(DataInputStream, LongArrayBitVector)
public static LongArrayBitVector readFast(java.io.DataInputStream dis, LongArrayBitVector bv) throws java.io.IOException
DataInputStream
.
This method is similar in purpose to readFast(DataInputStream)
, but it allows reuse of the bit vector.
dis
- a data input stream.bv
- a long-array bit vector.
bv
, filled with the next bit vector in the stream, as saved by writeFast(BitVector, DataOutputStream)
.
java.io.IOException
writeFast(BitVector, DataOutputStream)
,
readFast(DataInputStream)
public static BitVectors.OfflineBitVectorIterable makeOffline(java.util.Iterator<? extends BitVector> iterator) throws java.io.IOException
This method dumps an iterator object on disk and exposes the dumped file as a new iterable. It is useful whenever the iterable must be available, but it is not possible to keep it in core memory, or when the iterator must be scanned multiple times.
Warning: the BitVectors.OfflineBitVectorIterable
returned
by this method is SafelyCloseable
, and should always be closed to
delete the temporary file containing the iterable. The BitVectors.OfflineBitVectorIterator
returned by
the returned iterable is SafelyCloseable
, and should always be closed
to avoid exceeding the maximum number of open files; all exhausted iterators,
however, will be closed automagically.
iterator
- an iterator containing bit vectors.
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |