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

public class ObjectVector<T> extends AbstractVector
A generic vector.
See Also:
  • Constructor Details

    • ObjectVector

      public ObjectVector(String name, T[] vector)
      Constructor.
      Parameters:
      name - the name of vector.
      vector - the elements of vector.
    • ObjectVector

      public ObjectVector(StructField field, T[] vector)
      Constructor.
      Parameters:
      field - the struct field of vector.
      vector - the elements of vector.
  • Method Details

    • of

      public static ObjectVector<boolean[]> of(String name, boolean[]... vector)
      Creates a boolean array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<char[]> of(String name, char[]... vector)
      Creates a char array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<byte[]> of(String name, byte[]... vector)
      Creates a byte array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<short[]> of(String name, short[]... vector)
      Creates a short integer array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<int[]> of(String name, int[]... vector)
      Creates an integer array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<long[]> of(String name, long[]... vector)
      Creates a long integer array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<float[]> of(String name, float[]... vector)
      Creates a float array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • of

      public static ObjectVector<double[]> of(String name, double[]... vector)
      Creates a double array vector.
      Parameters:
      name - the name of vector.
      vector - the data of vector.
      Returns:
      the vector.
    • withName

      public ObjectVector<T> withName(String name)
      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

      public Stream<T> 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

      public List<T> 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

      public void set(int i, Object value)
      Description copied from interface: ValueVector
      Sets the value at position i.
      Parameters:
      i - the index.
      value - the new value.
    • get

      public ObjectVector<T> get(Index index)
      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

      public T get(int i)
      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.