Package elki.data
Class ByteVector
- java.lang.Object
-
- elki.data.ByteVector
-
- All Implemented Interfaces:
FeatureVector<java.lang.Number>,NumberVector,SpatialComparable
public class ByteVector extends java.lang.Object implements NumberVector
Vector usingbyte[]storage.- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classByteVector.FactoryFactory for Byte vectors.static classByteVector.ShortSerializerSerialization class for dense Byte vectors with up toShort.MAX_VALUEdimensions, by using a short for storing the dimensionality.static classByteVector.SmallSerializerSerialization class for dense Byte vectors with up to 127 dimensions, by using a byte for storing the dimensionality.
-
Field Summary
Fields Modifier and Type Field Description static ByteBufferSerializer<ByteVector>BYTE_SERIALIZERSerializer for up to 127 dimensions.static ByteBufferSerializer<ByteVector>SHORT_SERIALIZERSerializer for up to 2^15-1 dimensions.static ByteVector.FactorySTATICStatic instance (object factory).private byte[]valuesKeeps the values of the real vector.-
Fields inherited from interface elki.data.FeatureVector
TYPE
-
Fields inherited from interface elki.data.NumberVector
ATTRIBUTE_SEPARATOR, FIELD, FIELD_1D, FIELD_2D, VARIABLE_LENGTH
-
-
Constructor Summary
Constructors Modifier Constructor Description ByteVector(byte[] values)Create an ByteVector consisting of the given Byte values.privateByteVector(byte[] values, boolean nocopy)Private constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description bytebyteValue(int dimension)Returns the value in the specified dimension as byte.doubledoubleValue(int dimension)Returns the value in the specified dimension as double.intgetDimensionality()The dimensionality of the vector space where of this FeatureVector of V is an element.java.lang.BytegetValue(int dimension)Deprecated.byte[]getValues()Get a copy of the raw byte[] array.longlongValue(int dimension)Returns the value in the specified dimension as long.double[]toArray()Returns a double array copy of this vector.java.lang.StringtoString()Returns a String representation of the FeatureVector of V as a line that is suitable to be printed in a sequential file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.data.NumberVector
floatValue, getMax, getMin, intValue, shortValue
-
-
-
-
Field Detail
-
STATIC
public static final ByteVector.Factory STATIC
Static instance (object factory).
-
BYTE_SERIALIZER
public static final ByteBufferSerializer<ByteVector> BYTE_SERIALIZER
Serializer for up to 127 dimensions.
-
SHORT_SERIALIZER
public static final ByteBufferSerializer<ByteVector> SHORT_SERIALIZER
Serializer for up to 2^15-1 dimensions.
-
values
private final byte[] values
Keeps the values of the real vector.
-
-
Constructor Detail
-
ByteVector
private ByteVector(byte[] values, boolean nocopy)Private constructor. NOT for public use.- Parameters:
values- Value datanocopy- Flag to use without copying.
-
ByteVector
public ByteVector(byte[] values)
Create an ByteVector consisting of the given Byte values.- Parameters:
values- the values to be set as values of the ByteVector
-
-
Method Detail
-
getDimensionality
public int getDimensionality()
Description copied from interface:FeatureVectorThe dimensionality of the vector space where of this FeatureVector of V is an element.- Specified by:
getDimensionalityin interfaceFeatureVector<java.lang.Number>- Specified by:
getDimensionalityin interfaceSpatialComparable- Returns:
- the number of dimensions of this FeatureVector of V
-
getValue
@Deprecated public java.lang.Byte getValue(int dimension)
Deprecated.Description copied from interface:FeatureVectorReturns the value in the specified dimension.- Specified by:
getValuein interfaceFeatureVector<java.lang.Number>- Specified by:
getValuein interfaceNumberVector- Parameters:
dimension- the desired dimension, where 0 ≤ dimension ≤this.getDimensionality()-1- Returns:
- the value in the specified dimension
-
doubleValue
public double doubleValue(int dimension)
Description copied from interface:NumberVectorReturns the value in the specified dimension as double.Note: this might seem redundant with respect to
getValue(dim).doubleValue(), but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
doubleValuein interfaceNumberVector- Parameters:
dimension- the desired dimension, where 0 ≤ dimension <this.getDimensionality()- Returns:
- the value in the specified dimension
-
longValue
public long longValue(int dimension)
Description copied from interface:NumberVectorReturns the value in the specified dimension as long.Note: this might seem redundant with respect to
getValue(dim).longValue(), but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
longValuein interfaceNumberVector- Parameters:
dimension- the desired dimension, where 0 ≤ dimension <this.getDimensionality()- Returns:
- the value in the specified dimension
-
byteValue
public byte byteValue(int dimension)
Description copied from interface:NumberVectorReturns the value in the specified dimension as byte.Note: this might seem redundant with respect to
getValue(dim).byteValue(), but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
byteValuein interfaceNumberVector- Parameters:
dimension- the desired dimension, where 0 ≤ dimension <this.getDimensionality()- Returns:
- the value in the specified dimension
-
getValues
public byte[] getValues()
Get a copy of the raw byte[] array.- Returns:
- copy of values array.
-
toArray
public double[] toArray()
Description copied from interface:NumberVectorReturns a double array copy of this vector.- Specified by:
toArrayin interfaceNumberVector- Returns:
- Copy as
double[]
-
toString
public java.lang.String toString()
Description copied from interface:FeatureVectorReturns a String representation of the FeatureVector of V as a line that is suitable to be printed in a sequential file.- Specified by:
toStringin interfaceFeatureVector<java.lang.Number>- Overrides:
toStringin classjava.lang.Object- Returns:
- a String representation of the FeatureVector of V
-
-