public class BitVector extends AbstractNumberVector<BitVector,Bit> implements ByteBufferSerializer<BitVector>
Modifier and Type | Class and Description |
---|---|
static class |
BitVector.Parameterizer
Parameterization class
|
Modifier and Type | Field and Description |
---|---|
private BitSet |
bits
Storing the bits.
|
private int |
dimensionality
Dimensionality of this bit vector.
|
static BitVector |
STATIC
Static instance.
|
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.
|
BitVector |
fromByteBuffer(ByteBuffer buffer)
Deserialize an object from a byte buffer (e.g. disk)
|
BitSet |
getBits()
Returns a copy of the bits currently set in this BitVector.
|
int |
getByteSize(BitVector vec)
Get the size of the object in bytes.
|
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 binary vector space of which this BitVector is an
element.
|
Bit |
getValue(int dimension)
Returns the value in the specified dimension.
|
long |
longValue(int dimension)
Returns the value in the specified dimension as long.
|
<A> BitVector |
newFeatureVector(A array,
ArrayAdapter<Bit,A> adapter)
Returns a new FeatureVector of V for the given values.
|
<A> BitVector |
newNumberVector(A array,
NumberArrayAdapter<?,A> adapter)
Instantiate from any number-array like object.
|
void |
toByteBuffer(ByteBuffer buffer,
BitVector vec)
Serialize the object to a byte array (e.g. disk)
|
String |
toString()
Returns a String representation of this BitVector.
|
byteValue, floatValue, getMax, getMin, hashCode, intValue, newNumberVector, shortValue
public static final BitVector STATIC
private BitSet bits
private 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()
getDimensionality
in interface FeatureVector<BitVector,Bit>
getDimensionality
in interface SpatialComparable
FeatureVector.getDimensionality()
public Bit getValue(int dimension)
getValue
in interface FeatureVector<BitVector,Bit>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
FeatureVector.getValue(int)
public double doubleValue(int dimension)
doubleValue
in interface NumberVector<BitVector,Bit>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
NumberVector.doubleValue(int)
public long longValue(int dimension)
longValue
in interface NumberVector<BitVector,Bit>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
NumberVector.longValue(int)
public Vector getColumnVector()
getDimensionality()
rows the values of this BitVector as
double values.getColumnVector
in interface NumberVector<BitVector,Bit>
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
.toString
in interface FeatureVector<BitVector,Bit>
toString
in class Object
Object.toString()
public boolean equals(Object obj)
equals
in class AbstractNumberVector<BitVector,Bit>
obj
- another Objectpublic <A> BitVector newFeatureVector(A array, ArrayAdapter<Bit,A> adapter)
FeatureVector
newFeatureVector
in interface FeatureVector<BitVector,Bit>
A
- Array typearray
- the values of the featureVectoradapter
- adapter classpublic <A> BitVector newNumberVector(A array, NumberArrayAdapter<?,A> adapter)
NumberVector
newNumberVector
in interface NumberVector<BitVector,Bit>
A
- Array typearray
- Arrayadapter
- Adapterpublic BitVector fromByteBuffer(ByteBuffer buffer) throws IOException
ByteBufferSerializer
fromByteBuffer
in interface ByteBufferSerializer<BitVector>
buffer
- Data array to processIOException
public void toByteBuffer(ByteBuffer buffer, BitVector vec) throws IOException
ByteBufferSerializer
toByteBuffer
in interface ByteBufferSerializer<BitVector>
buffer
- Buffer to serialize tovec
- Object to serializeIOException
public int getByteSize(BitVector vec)
ByteBufferSerializer
getByteSize
in interface ByteBufferSerializer<BitVector>
vec
- Object to serialize