Package smile.data.vector
Class ObjectVector<T>
java.lang.Object
smile.data.vector.AbstractVector
smile.data.vector.ObjectVector<T>
- Type Parameters:
T
- the data type of vector elements.
- All Implemented Interfaces:
Serializable
,ValueVector
- Direct Known Subclasses:
NumberVector
,StringVector
A generic vector.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionObjectVector
(String name, T[] vector) Constructor.ObjectVector
(StructField field, T[] vector) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondistinct()
Returns the distinct values.get
(int i) Returns the value at position i, which may be null.Returns a new vector with selected entries.boolean
getBoolean
(int i) Returns the boolean value at position i.byte
getByte
(int i) Returns the byte value at position i.char
getChar
(int i) Returns the character value at position i.double
getDouble
(int i) Returns the double value at position i.float
getFloat
(int i) Returns the float value at position i.int
getInt
(int i) Returns the integer value at position i.long
getLong
(int i) Returns the long value at position i.int
Returns the number of null/missing values in this vector.short
getShort
(int i) Returns the short value at position i.boolean
Returns true if the values of vector may be null.boolean
isNullAt
(int i) Returns true if the value at the given index is null/missing.static ObjectVector
<boolean[]> Creates a boolean array vector.static ObjectVector
<byte[]> Creates a byte array vector.static ObjectVector
<char[]> Creates a char array vector.static ObjectVector
<double[]> Creates a double array vector.static ObjectVector
<float[]> Creates a float array vector.static ObjectVector
<int[]> Creates an integer array vector.static ObjectVector
<long[]> Creates a long integer array vector.static ObjectVector
<short[]> Creates a short integer array vector.void
Sets the value at position i.int
size()
Returns the number of elements in the vector.stream()
Returns a stream consisting of the elements of this vector.Returns the vector with the new name.Methods inherited from class smile.data.vector.AbstractVector
field, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface smile.data.vector.ValueVector
anyNull, apply, apply, doubleStream, dtype, eq, ge, get, getScale, getString, gt, intStream, isin, isNull, le, longStream, lt, measure, name, ne, slice, slice, toDoubleArray, toIntArray, toLongArray, toStringArray, toStringArray, update
-
Constructor Details
-
ObjectVector
Constructor.- Parameters:
name
- the name of vector.vector
- the elements of vector.
-
ObjectVector
Constructor.- Parameters:
field
- the struct field of vector.vector
- the elements of vector.
-
-
Method Details
-
of
Creates a boolean array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a char array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a byte array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a short integer array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates an integer array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a long integer array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a float array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a double array vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
withName
Description copied from interface:ValueVector
Returns the vector with the new name.- Parameters:
name
- the new name.- Returns:
- the vector with the new name.
-
stream
Description copied from interface:ValueVector
Returns a stream consisting of the elements of this vector.- Returns:
- a stream consisting of the elements of this vector.
-
distinct
Returns the distinct values.- Returns:
- the distinct values.
-
size
public int size()Description copied from interface:ValueVector
Returns the number of elements in the vector.- Returns:
- the number of elements in the vector.
-
set
Description copied from interface:ValueVector
Sets the value at position i.- Parameters:
i
- the index.value
- the new value.
-
get
Description copied from interface:ValueVector
Returns a new vector with selected entries.- Parameters:
index
- the index of selected entries.- Returns:
- the new vector of selected entries.
-
get
Description copied from interface:ValueVector
Returns the value at position i, which may be null.- Parameters:
i
- the index.- Returns:
- the value.
-
getBoolean
public boolean getBoolean(int i) Description copied from interface:ValueVector
Returns the boolean value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getChar
public char getChar(int i) Description copied from interface:ValueVector
Returns the character value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getByte
public byte getByte(int i) Description copied from interface:ValueVector
Returns the byte value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getShort
public short getShort(int i) Description copied from interface:ValueVector
Returns the short value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getInt
public int getInt(int i) Description copied from interface:ValueVector
Returns the integer value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getLong
public long getLong(int i) Description copied from interface:ValueVector
Returns the long value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getFloat
public float getFloat(int i) Description copied from interface:ValueVector
Returns the float value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getDouble
public double getDouble(int i) Description copied from interface:ValueVector
Returns the double value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
isNullable
public boolean isNullable()Description copied from interface:ValueVector
Returns true if the values of vector may be null.- Returns:
- true if the values of vector may be null.
-
isNullAt
public boolean isNullAt(int i) Description copied from interface:ValueVector
Returns true if the value at the given index is null/missing.- Parameters:
i
- the index.- Returns:
- true if the value at the given index is null/missing.
-
getNullCount
public int getNullCount()Description copied from interface:ValueVector
Returns the number of null/missing values in this vector.- Returns:
- the number of null/missing values in this vector.
-