Package elki.data
Class IntegerVector
- java.lang.Object
-
- elki.data.IntegerVector
-
- All Implemented Interfaces:
FeatureVector<java.lang.Number>
,NumberVector
,SpatialComparable
public class IntegerVector extends java.lang.Object implements NumberVector
Vector type usingint[]
storage.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntegerVector.Factory
Factory for integer vectors.static class
IntegerVector.ShortSerializer
Serialization class for dense integer vectors with up toShort.MAX_VALUE
dimensions, by using a short for storing the dimensionality.static class
IntegerVector.SmallSerializer
Serialization class for dense integer vectors with up to 127 dimensions, by using a byte for storing the dimensionality.static class
IntegerVector.VariableSerializer
Serialization class for variable dimensionality by using VarInt encoding.
-
Field Summary
Fields Modifier and Type Field Description static ByteBufferSerializer<IntegerVector>
BYTE_SERIALIZER
Serializer for up to 127 dimensions.static ByteBufferSerializer<IntegerVector>
SHORT_SERIALIZER
Serializer for up to 2^15-1 dimensions.static IntegerVector.Factory
STATIC
Static instance (object factory).private int[]
values
Keeps the values of the real vector.static ByteBufferSerializer<IntegerVector>
VARIABLE_SERIALIZER
Serializer 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 IntegerVector(int[] values)
Create an IntegerVector consisting of the given integer values.private
IntegerVector(int[] values, boolean nocopy)
Private constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description double
doubleValue(int dimension)
Returns the value in the specified dimension as double.int
getDimensionality()
The dimensionality of the vector space where of this FeatureVector of V is an element.java.lang.Integer
getValue(int dimension)
Deprecated.int
intValue(int dimension)
Returns the value in the specified dimension as int.long
longValue(int dimension)
Returns the value in the specified dimension as long.double[]
toArray()
Returns a double array copy of this vector.java.lang.String
toString()
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, shortValue
-
-
-
-
Field Detail
-
STATIC
public static final IntegerVector.Factory STATIC
Static instance (object factory).
-
BYTE_SERIALIZER
public static final ByteBufferSerializer<IntegerVector> BYTE_SERIALIZER
Serializer for up to 127 dimensions.
-
SHORT_SERIALIZER
public static final ByteBufferSerializer<IntegerVector> SHORT_SERIALIZER
Serializer for up to 2^15-1 dimensions.
-
VARIABLE_SERIALIZER
public static final ByteBufferSerializer<IntegerVector> VARIABLE_SERIALIZER
Serializer using varint encoding.
-
values
private final int[] values
Keeps the values of the real vector.
-
-
Constructor Detail
-
IntegerVector
private IntegerVector(int[] values, boolean nocopy)
Private constructor. NOT for public use.- Parameters:
values
- Value datanocopy
- Flag to use without copying.
-
IntegerVector
public IntegerVector(int[] values)
Create an IntegerVector consisting of the given integer values.- Parameters:
values
- the values to be set as values of the IntegerVector
-
-
Method Detail
-
getDimensionality
public int getDimensionality()
Description copied from interface:FeatureVector
The dimensionality of the vector space where of this FeatureVector of V is an element.- Specified by:
getDimensionality
in interfaceFeatureVector<java.lang.Number>
- Specified by:
getDimensionality
in interfaceSpatialComparable
- Returns:
- the number of dimensions of this FeatureVector of V
-
getValue
@Deprecated public java.lang.Integer getValue(int dimension)
Deprecated.Returns the value of the specified attribute.- Specified by:
getValue
in interfaceFeatureVector<java.lang.Number>
- Specified by:
getValue
in 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:NumberVector
Returns 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:
doubleValue
in 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:NumberVector
Returns 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:
longValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
intValue
public int intValue(int dimension)
Description copied from interface:NumberVector
Returns the value in the specified dimension as int.Note: this might seem redundant with respect to
getValue(dim).intValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
intValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
toArray
public double[] toArray()
Description copied from interface:NumberVector
Returns a double array copy of this vector.- Specified by:
toArray
in interfaceNumberVector
- Returns:
- Copy as
double[]
-
toString
public java.lang.String toString()
Description copied from interface:FeatureVector
Returns a String representation of the FeatureVector of V as a line that is suitable to be printed in a sequential file.- Specified by:
toString
in interfaceFeatureVector<java.lang.Number>
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a String representation of the FeatureVector of V
-
-