Package smile.data.vector
Interface Vector<T>
- Type Parameters:
T
- the data type of vector elements.
- All Superinterfaces:
BaseVector<T,
,T, Stream<T>> Serializable
- All Known Subinterfaces:
NumberVector
,StringVector
An immutable generic vector.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
anyNull()
Returns true if there are any NULL values in this row.distinct()
Returns the distinct values.get
(int... index) Returns a new vector with selected entries.default boolean
getBoolean
(int i) Returns the boolean value at position i.default byte
getByte
(int i) Returns the byte value at position i.default char
getChar
(int i) Returns the character value at position i.default double
getDouble
(int i) Returns the double value at position i.default float
getFloat
(int i) Returns the float value at position i.default int
getInt
(int i) Returns the integer value at position i.default long
getLong
(int i) Returns the long value at position i.default short
getShort
(int i) Returns the short value at position i.default boolean
isNullAt
(int i) Checks if the value at position i is null.static <T> Vector
<T> Creates a named vector.static <T> Vector
<T> Creates a named vector.static <T> Vector
<T> of
(StructField field, T[] vector) Creates a named vector.T[]
toArray()
Returns the array of elements.toDate()
Returns a vector of LocalDate.Returns a vector of LocalDateTime.default String
toString
(int n) Returns the string representation of vector.toTime()
Returns a vector of LocalTime.Methods inherited from interface smile.data.vector.BaseVector
apply, apply, array, field, get, measure, name, size, stream, toDoubleArray, toDoubleArray, toIntArray, toIntArray, toStringArray, toStringArray, type
-
Method Details
-
get
Description copied from interface:BaseVector
Returns a new vector with selected entries. -
toArray
T[] toArray()Returns the array of elements.- Returns:
- the array of elements.
-
toDate
Returns a vector of LocalDate. If the vector is of strings, it uses the default ISO date formatter that parses a date without an offset, such as '2011-12-03'. If the vector is of other time related objects such as Instant, java.util.Date, java.sql.Timestamp, etc., do a proper conversion.- Returns:
- the date vector.
-
toTime
Returns a vector of LocalTime. If the vector is of strings, it uses the default ISO time formatter that parses a time without an offset, such as '10:15' or '10:15:30'. If the vector is of other time related objects such as Instant, java.util.Date, java.sql.Timestamp, etc., do a proper conversion.- Returns:
- the time vector.
-
toDateTime
Vector<LocalDateTime> toDateTime()Returns a vector of LocalDateTime. If the vector is of strings, it uses the default ISO date time formatter that parses a date without an offset, such as '2011-12-03T10:15:30'. If the vector is of other time related objects such as Instant, java.util.Date, java.sql.Timestamp, etc., do a proper conversion.- Returns:
- the datetime vector.
-
distinct
Returns the distinct values.- Returns:
- the distinct values.
-
getBoolean
default boolean getBoolean(int i) Description copied from interface:BaseVector
Returns the boolean value at position i.- Specified by:
getBoolean
in interfaceBaseVector<T,
T, Stream<T>> - Parameters:
i
- the index.- Returns:
- the value.
-
getChar
default char getChar(int i) Description copied from interface:BaseVector
Returns the character value at position i. -
getByte
default byte getByte(int i) Description copied from interface:BaseVector
Returns the byte value at position i. -
getShort
default short getShort(int i) Description copied from interface:BaseVector
Returns the short value at position i. -
getInt
default int getInt(int i) Description copied from interface:BaseVector
Returns the integer value at position i. -
getLong
default long getLong(int i) Description copied from interface:BaseVector
Returns the long value at position i. -
getFloat
default float getFloat(int i) Description copied from interface:BaseVector
Returns the float value at position i. -
getDouble
default double getDouble(int i) Description copied from interface:BaseVector
Returns the double value at position i. -
isNullAt
default boolean isNullAt(int i) Checks if the value at position i is null.- Parameters:
i
- the index.- Returns:
- true if the value is null.
-
anyNull
default boolean anyNull()Returns true if there are any NULL values in this row.- Returns:
- true if there are any NULL values in this row.
-
toString
Returns the string representation of vector.- Parameters:
n
- the number of elements to show.- Returns:
- the string representation of vector.
-
of
Creates a named vector.- Type Parameters:
T
- the data type of vector elements.- Parameters:
name
- the name of vector.clazz
- the class of data type.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a named vector.- Type Parameters:
T
- the data type of vector elements.- Parameters:
name
- the name of vector.type
- the data type of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a named vector.- Type Parameters:
T
- the data type of vector elements.- Parameters:
field
- the struct field of vector.vector
- the data of vector.- Returns:
- the vector.
-