public class BitVector extends AbstractNumberVector<Bit>
Modifier and Type | Class and Description |
---|---|
static class |
BitVector.Factory
Factory for bit vectors.
|
static class |
BitVector.ShortSerializer
Serialization class for dense integer vectors with up to
Short.MAX_VALUE dimensions, by using a short for storing the
dimensionality. |
Modifier and Type | Field and Description |
---|---|
private BitSet |
bits
Storing the bits.
|
private int |
dimensionality
Dimensionality of this bit vector.
|
static BitVector.Factory |
FACTORY
Static instance.
|
static ByteBufferSerializer<BitVector> |
SHORT_SERIALIZER
Serializer for up to 2^15-1 dimensions.
|
ATTRIBUTE_SEPARATOR
Constructor and Description |
---|
BitVector(Bit[] bits)
Provides a new BitVector corresponding to the bits in the given array.
|
BitVector(BitSet bits,
int dimensionality)
Provides a new BitVector corresponding to the specified bits and of the
specified dimensionality.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(BitSet bitset)
Returns whether this BitVector contains all bits that are set to true in
the specified BitSet.
|
double |
doubleValue(int dimension)
Returns the value in the specified dimension as double.
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this BitVector.
|
BitSet |
getBits()
Returns a copy of the bits currently set in this BitVector.
|
Vector |
getColumnVector()
Returns a Vector representing in one column and
getDimensionality() rows the values of this BitVector as
double values. |
int |
getDimensionality()
The dimensionality of the vector space where of this FeatureVector of V is
an element.
|
Bit |
getValue(int dimension)
Deprecated.
|
long |
longValue(int dimension)
Returns the value in the specified dimension as long.
|
String |
toString()
Returns a String representation of this BitVector.
|
byteValue, floatValue, getMax, getMin, intValue, shortValue
public static final BitVector.Factory FACTORY
public static final ByteBufferSerializer<BitVector> SHORT_SERIALIZER
private final BitSet bits
private final int dimensionality
public BitVector(BitSet bits, int dimensionality) throws IllegalArgumentException
bits
- the bits to be set in this BitVectordimensionality
- the dimensionality of this BitVectorIllegalArgumentException
- if the specified dimensionality is to
small to match the given BitSetpublic BitVector(Bit[] bits)
bits
- an array of bits specifying the bits in this bit vectorpublic int getDimensionality()
FeatureVector
@Deprecated public Bit getValue(int dimension)
FeatureVector
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
public double doubleValue(int dimension)
NumberVector
getValue(dim).doubleValue()
, but usually this is much more
efficient due to boxing/unboxing cost.dimension
- the desired dimension, where 0 ≤ dimension <
this.getDimensionality()
public long longValue(int dimension)
NumberVector
getValue(dim).longValue()
, but usually this is much more efficient
due to boxing/unboxing cost.dimension
- the desired dimension, where 0 ≤ dimension <
this.getDimensionality()
public Vector getColumnVector()
getDimensionality()
rows the values of this BitVector as
double values.getDimensionality()
rows the values of this BitVector
as double valuesNumberVector.getColumnVector()
public boolean contains(BitSet bitset)
bitset
- the bits to inspect in this BitVectorpublic BitSet getBits()
public String toString()
BitVectorLabelParser
.
Returns a String representation of the FeatureVector of V as a line that is
suitable to be printed in a sequential file.toString
in interface FeatureVector<Bit>
toString
in class Object