Package elki.data
Class ShortVector
- java.lang.Object
-
- elki.data.ShortVector
-
- All Implemented Interfaces:
FeatureVector<java.lang.Number>,NumberVector,SpatialComparable
public class ShortVector extends java.lang.Object implements NumberVector
Vector type usingshort[]storage.- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShortVector.FactoryFactory for Short vectors.static classShortVector.ShortSerializerSerialization class for dense Short vectors with up toShort.MAX_VALUEdimensions, by using a short for storing the dimensionality.static classShortVector.VariableSerializerSerialization class for variable dimensionality by using VarInt encoding.
-
Field Summary
Fields Modifier and Type Field Description static ByteBufferSerializer<ShortVector>SHORT_SERIALIZERSerializer for up to 2^15-1 dimensions.static ShortVector.FactorySTATICStatic instance (object factory).private short[]valuesKeeps the values of the real vector.static ByteBufferSerializer<ShortVector>VARIABLE_SERIALIZERSerializer using varint encoding.-
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 ShortVector(short[] values)Create an ShortVector consisting of the given Short values.privateShortVector(short[] values, boolean nocopy)Private constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.ShortgetValue(int dimension)Deprecated.short[]getValues()Get a copy of the raw short[] array.longlongValue(int dimension)Returns the value in the specified dimension as long.shortshortValue(int dimension)Returns the value in the specified dimension as short.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
byteValue, floatValue, getMax, getMin, intValue
-
-
-
-
Field Detail
-
STATIC
public static final ShortVector.Factory STATIC
Static instance (object factory).
-
SHORT_SERIALIZER
public static final ByteBufferSerializer<ShortVector> SHORT_SERIALIZER
Serializer for up to 2^15-1 dimensions.
-
VARIABLE_SERIALIZER
public static final ByteBufferSerializer<ShortVector> VARIABLE_SERIALIZER
Serializer using varint encoding.
-
values
private final short[] values
Keeps the values of the real vector.
-
-
Constructor Detail
-
ShortVector
private ShortVector(short[] values, boolean nocopy)Private constructor. NOT for public use.- Parameters:
values- Value datanocopy- Flag to use without copying.
-
ShortVector
public ShortVector(short[] values)
Create an ShortVector consisting of the given Short values.- Parameters:
values- the values to be set as values of the ShortVector
-
-
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.Short getValue(int dimension)
Deprecated.Returns the value of the specified attribute.- Specified by:
getValuein interfaceFeatureVector<java.lang.Number>- Specified by:
getValuein interfaceNumberVector- Parameters:
dimension- the selected attribute. Attributes are counted starting with 0.- Returns:
- the value in the specified dimension
- Throws:
java.lang.IllegalArgumentException- if the specified dimension is out of range of the possible attributes
-
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
-
shortValue
public short shortValue(int dimension)
Description copied from interface:NumberVectorReturns the value in the specified dimension as short.Note: this might seem redundant with respect to
getValue(dim).shortValue(), but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
shortValuein interfaceNumberVector- Parameters:
dimension- the desired dimension, where 0 ≤ dimension <this.getDimensionality()- Returns:
- the value in the specified dimension
-
getValues
public short[] getValues()
Get a copy of the raw short[] 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
-
-