Interface Column<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean allMatch​(Predicate<? super T> test)
      Returns true if all rows satisfy the predicate, false otherwise
      default boolean anyMatch​(Predicate<? super T> test)
      Returns true if any row satisfies the predicate, false otherwise
      Column<T> append​(T value)
      Appends value to the bottom of this column and return this column
      Column<T> append​(Column<T> column)
      Appends all the values in the argument to the bottom of this column and return this column
      Column<T> append​(Column<T> column, int row)
      Appends the value at the given row in the given column to the bottom of this column and return this column
      Column<T> appendCell​(String stringValue)
      Add one element to the bottom of this column and set its value to the parsed value of the given String.
      Column<T> appendCell​(String stringValue, AbstractColumnParser<?> parser)
      Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parser
      Column<T> appendMissing()
      Appends a missing value appropriate to the column
      Column<T> appendObj​(Object value)
      Appends the given value to the bottom of this column and return this column
      byte[] asBytes​(int rowNumber)
      Returns the contents of the cell at rowNumber as a byte[].
      default List<T> asList()
      Returns a list of all the elements in this column
      T[] asObjectArray()
      Returns an array of objects as appropriate for my type of column
      Set<T> asSet()
      Returns a Set containing all the unique values in this column
      StringColumn asStringColumn()
      Returns a StringColumn consisting of the (unformatted) String representation of this column values
      int byteSize()
      Returns the width of a cell in this column, in bytes.
      void clear()
      Removes all elements TODO: Make this return this column
      default int columnWidth()
      Returns the width of the column in characters, for printing
      default boolean contains​(T object)
      Returns true if the given object appears in this column, and false otherwise
      Column<T> copy()
      Returns a deep copy of the receiver
      default int count​(Predicate<? super T> test)
      Counts the number of rows satisfying predicate
      default int count​(Predicate<? super T> test, int max)
      Counts the number of rows satisfying predicate, but only upto the max value
      int countMissing()
      Returns the count of missing values in this column.
      default int countUnique()
      Returns the count of unique values in this column.
      Column<T> emptyCopy()
      Returns a copy of the receiver with no data.
      Column<T> emptyCopy​(int rowSize)
      Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
      boolean equals​(int rowNumber1, int rowNumber2)
      Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2
      default Column<T> filter​(Predicate<? super T> test)
      Returns a new Column of the same type with only those rows satisfying the predicate
      default Column<T> first​(int numRows)
      Returns a column of the same type containing the first numRows of this column.
      T get​(int row)
      Returns the value at the given zero-based index
      String getString​(int row)
      Returns a string representation of the value at the given row.
      String getUnformattedString​(int r)
      Returns a String representation of the value at index r, without any formatting applied
      int indexOf​(Object o)
      Returns the index of the first occurrence of o in the column or -1 if the element is not in the column.
      default Column<T> inRange​(int start, int end)
      Returns a column containing the rows in this column beginning with start inclusive, and ending with end exclusive
      default Interpolator<T> interpolate()
      Provides the ability to create a new column with missing cells filled based off the value of nearby cells.
      boolean isEmpty()
      Returns true if the column has no data
      Selection isMissing()
      Returns a selection containing an index for every missing value in this column
      boolean isMissing​(int rowNumber)
      Returns true if the value at rowNumber is missing
      Selection isNotMissing()
      Returns a selection containing an index for every non-missing value in this column
      Column<T> lag​(int n)
      Returns a column of the same type and size as the receiver, containing the receivers values offset by n.
      default Column<T> last​(int numRows)
      Returns a column of the same type containing the last numRows of this column.
      int lastIndexOf​(Object o)
      Returns the index of the last occurrence of o in the column or -1 if the element is not in the column.
      default Column<T> lead​(int n)
      Returns a column of the same type as the receiver, containing the receivers values offset -n For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.
      default <R,​C extends Column<R>>
      C
      map​(Function<? super T,​? extends R> fun, Function<String,​C> creator)
      Maps the function across all rows, appending the results to the created Column.
      default Column<T> map​(Function<? super T,​? extends T> fun)
      Maps the function across all rows, appending the results to a new Column of the same type
      default <R,​C extends Column<R>>
      C
      mapInto​(Function<? super T,​? extends R> fun, C into)
      Maps the function across all rows, storing the results into the provided Column.
      default Optional<T> max​(Comparator<? super T> comp)
      Returns the maximum row according to the provided Comparator
      default Column<T> max​(Column<T> other)
      Returns a column containing the element-wise min between this column and other column
      default Optional<T> min​(Comparator<? super T> comp)
      Returns the minimum value according to the provided Comparator
      default Column<T> min​(Column<T> other)
      Returns a column containing the element-wise min between this column and other column
      String name()
      Returns the column's name.
      default boolean noneMatch​(Predicate<? super T> test)
      Returns true if no row satisfies the predicate, false otherwise
      AbstractColumnParser<T> parser()
      Returns the parser used by appendCell(String) ()}.
      default String print()
      TODO(lwhite): Print n from the top and bottom, like a table;
      default Optional<T> reduce​(BinaryOperator<T> op)
      Reduction with binary operator
      default T reduce​(T initial, BinaryOperator<T> op)
      Reduction with binary operator and initial value
      Column<T> removeMissing()
      Returns a copy of this column with the missing values removed
      default RollingColumn rolling​(int windowSize)
      Returns a RollingColumn with the given windowSize, which can be used for performing calculations on rolling subsets of my data
      it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
      Returns an IntComparator for sorting my rows
      default Column<T> sampleN​(int n)
      Returns a column containing a random sample of the values in this column
      default Column<T> sampleX​(double proportion)
      Returns a table consisting of randomly selected values from this column.
      default Column<T> set​(int row, String stringValue, AbstractColumnParser<?> parser)
      Sets the value at row to the parsed value of the given String using the given parser and returns this column
      Column<T> set​(int row, T value)
      Sets the value at index row to the given value and return this column
      Column<T> set​(int row, Column<T> sourceColumn, int sourceRow)
      Sets the value at row to the value at sourceRow in the given column and return this column
      default Column<T> set​(Predicate<T> condition, Column<T> other)
      Updates this column where values matching the selection are replaced with the corresponding value from the given column
      default Column<T> set​(Selection rowSelection, T newValue)
      Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria
      default Column<T> set​(Selection condition, Column<T> other)
      Updates this column where values matching the selection are replaced with the corresponding value from the given column
      Column<T> setMissing​(int i)
      Sets the value at index i to the missing-value indicator for this column type, and return this column
      default Column<T> setMissingTo​(T newValue)
      Sets the value of any missing data in the column to newValue and returns the same column
      Column<T> setName​(String name)
      Sets the columns name to the given string
      Column<T> setParser​(AbstractColumnParser<T> parser)
      Sets the parser used by appendCell(String)
      int size()
      Returns the number of elements in this column, including missing values
      void sortAscending()
      Sorts my values in ascending order
      void sortDescending()
      Sorts my values in descending order
      default Column<T> sorted​(Comparator<? super T> comp)
      Returns a new Column of the same type sorted according to the provided Comparator
      default Column<T> subset​(int[] rows)
      Return a column of the same type containing just those elements whose indexes are included in the given array
      Table summary()
      Returns a table containing a ColumnType specific summary of the data in this column
      default String title()  
      ColumnType type()
      Returns this column's ColumnType
      Column<T> unique()
      Returns a column of the same type containing only the unique values
      int valueHash​(int rowNumber)
      Returns an int suitable as a hash for the value in this column at the given index
      Column<T> where​(Selection selection)
      Returns a new column containing the subset referenced by the Selection
    • Method Detail

      • size

        int size()
        Returns the number of elements in this column, including missing values
      • summary

        Table summary()
        Returns a table containing a ColumnType specific summary of the data in this column
      • asObjectArray

        T[] asObjectArray()
        Returns an array of objects as appropriate for my type of column
      • countMissing

        int countMissing()
        Returns the count of missing values in this column.
        Returns:
        missing values as int
      • countUnique

        default int countUnique()
        Returns the count of unique values in this column.
        Returns:
        unique values as int
      • name

        String name()
        Returns the column's name.
        Returns:
        name as String
      • getString

        String getString​(int row)
        Returns a string representation of the value at the given row.
        Parameters:
        row - The index of the row.
        Returns:
        value as String
      • get

        T get​(int row)
        Returns the value at the given zero-based index
      • reduce

        default T reduce​(T initial,
                         BinaryOperator<T> op)
        Reduction with binary operator and initial value
        Parameters:
        initial - initial value
        op - the operator
        Returns:
        the result of reducing initial value and all rows with operator
      • reduce

        default Optional<T> reduce​(BinaryOperator<T> op)
        Reduction with binary operator
        Parameters:
        op - the operator
        Returns:
        Optional with the result of reducing all rows with operator
      • clear

        void clear()
        Removes all elements TODO: Make this return this column
      • sortAscending

        void sortAscending()
        Sorts my values in ascending order
      • sortDescending

        void sortDescending()
        Sorts my values in descending order
      • isEmpty

        boolean isEmpty()
        Returns true if the column has no data
        Returns:
        true if empty, false if not
      • rowComparator

        it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
        Returns an IntComparator for sorting my rows
      • title

        default String title()
      • isMissing

        Selection isMissing()
        Returns a selection containing an index for every missing value in this column
      • isNotMissing

        Selection isNotMissing()
        Returns a selection containing an index for every non-missing value in this column
      • byteSize

        int byteSize()
        Returns the width of a cell in this column, in bytes.
        Returns:
        width in bytes
      • asBytes

        byte[] asBytes​(int rowNumber)
        Returns the contents of the cell at rowNumber as a byte[].
        Parameters:
        rowNumber - index of the row
        Returns:
        content as byte[]
      • asSet

        Set<T> asSet()
        Returns a Set containing all the unique values in this column
      • rolling

        default RollingColumn rolling​(int windowSize)
        Returns a RollingColumn with the given windowSize, which can be used for performing calculations on rolling subsets of my data
        Parameters:
        windowSize - The number of elements to include in each calculation
        Returns:
        a RollingColumn
      • getUnformattedString

        String getUnformattedString​(int r)
        Returns a String representation of the value at index r, without any formatting applied
      • isMissing

        boolean isMissing​(int rowNumber)
        Returns true if the value at rowNumber is missing
      • print

        default String print()
        TODO(lwhite): Print n from the top and bottom, like a table;
      • columnWidth

        default int columnWidth()
        Returns the width of the column in characters, for printing
      • asList

        default List<T> asList()
        Returns a list of all the elements in this column

        Note, if a value in the column is missing, a null is added in it's place

      • contains

        default boolean contains​(T object)
        Returns true if the given object appears in this column, and false otherwise

        TODO override in column subtypes for performance

      • count

        default int count​(Predicate<? super T> test,
                          int max)
        Counts the number of rows satisfying predicate, but only upto the max value
        Parameters:
        test - the predicate
        max - the maximum number of rows to count
        Returns:
        the number of rows satisfying the predicate
      • count

        default int count​(Predicate<? super T> test)
        Counts the number of rows satisfying predicate
        Parameters:
        test - the predicate
        Returns:
        the number of rows satisfying the predicate
      • allMatch

        default boolean allMatch​(Predicate<? super T> test)
        Returns true if all rows satisfy the predicate, false otherwise
        Parameters:
        test - the predicate
        Returns:
        true if all rows satisfy the predicate, false otherwise
      • anyMatch

        default boolean anyMatch​(Predicate<? super T> test)
        Returns true if any row satisfies the predicate, false otherwise
        Parameters:
        test - the predicate
        Returns:
        true if any rows satisfies the predicate, false otherwise
      • noneMatch

        default boolean noneMatch​(Predicate<? super T> test)
        Returns true if no row satisfies the predicate, false otherwise
        Parameters:
        test - the predicate
        Returns:
        true if no row satisfies the predicate, false otherwise
      • max

        default Optional<T> max​(Comparator<? super T> comp)
        Returns the maximum row according to the provided Comparator
        Parameters:
        comp -
        Returns:
        the maximum row
      • min

        default Optional<T> min​(Comparator<? super T> comp)
        Returns the minimum value according to the provided Comparator
        Parameters:
        comp - the Comparator to use
        Returns:
        the minimum value
      • mapInto

        default <R,​C extends Column<R>> C mapInto​(Function<? super T,​? extends R> fun,
                                                        C into)
        Maps the function across all rows, storing the results into the provided Column.

        The target column must have at least the same number of rows.

        Parameters:
        fun - function to map
        into - Column into which results are set
        Returns:
        the provided Column
      • map

        default <R,​C extends Column<R>> C map​(Function<? super T,​? extends R> fun,
                                                    Function<String,​C> creator)
        Maps the function across all rows, appending the results to the created Column.

        Example:

         DoubleColumn d;
         StringColumn s = d.map(String::valueOf, StringColumn::create);
         
        Parameters:
        fun - function to map
        creator - the creator of the Column. Its String argument will be the name of the current column (see name())
        Returns:
        the Column with the results
      • setMissing

        Column<T> setMissing​(int i)
        Sets the value at index i to the missing-value indicator for this column type, and return this column
      • setMissingTo

        default Column<T> setMissingTo​(T newValue)
        Sets the value of any missing data in the column to newValue and returns the same column
        Parameters:
        newValue - the value to be used for all missing data in this column
        Returns:
        the column updated
      • filter

        default Column<T> filter​(Predicate<? super T> test)
        Returns a new Column of the same type with only those rows satisfying the predicate
        Parameters:
        test - the predicate
        Returns:
        a new Column of the same type with only those rows satisfying the predicate
      • subset

        default Column<T> subset​(int[] rows)
        Return a column of the same type containing just those elements whose indexes are included in the given array
      • sorted

        default Column<T> sorted​(Comparator<? super T> comp)
        Returns a new Column of the same type sorted according to the provided Comparator
        Parameters:
        comp - the Comparator
        Returns:
        a sorted Column
      • emptyCopy

        Column<T> emptyCopy()
        Returns a copy of the receiver with no data. The column name and type are the same.
        Returns:
        a empty copy of Column
      • copy

        Column<T> copy()
        Returns a deep copy of the receiver
        Returns:
        a Column
      • emptyCopy

        Column<T> emptyCopy​(int rowSize)
        Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
        Parameters:
        rowSize - the initial row size
        Returns:
        a Column
      • map

        default Column<T> map​(Function<? super T,​? extends T> fun)
        Maps the function across all rows, appending the results to a new Column of the same type
        Parameters:
        fun - function to map
        Returns:
        the Column with the results
      • min

        default Column<T> min​(Column<T> other)
        Returns a column containing the element-wise min between this column and other column

        TODO(lwhite) Override in column subtypes for better performance

      • max

        default Column<T> max​(Column<T> other)
        Returns a column containing the element-wise min between this column and other column

        TODO(lwhite) Override in column subtypes for better performance

      • set

        default Column<T> set​(Predicate<T> condition,
                              Column<T> other)
        Updates this column where values matching the selection are replaced with the corresponding value from the given column
      • set

        default Column<T> set​(Selection condition,
                              Column<T> other)
        Updates this column where values matching the selection are replaced with the corresponding value from the given column
      • lead

        default Column<T> lead​(int n)
        Returns a column of the same type as the receiver, containing the receivers values offset -n For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.
      • set

        default Column<T> set​(Selection rowSelection,
                              T newValue)
        Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria
      • lag

        Column<T> lag​(int n)
        Returns a column of the same type and size as the receiver, containing the receivers values offset by n.

        For example if you lag a column containing 2, 3, 4 by 1, you get a column containing NA, 2, 3

      • appendCell

        Column<T> appendCell​(String stringValue)
        Add one element to the bottom of this column and set its value to the parsed value of the given String. Parsing is type-specific
      • appendCell

        Column<T> appendCell​(String stringValue,
                             AbstractColumnParser<?> parser)
        Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parser
      • set

        Column<T> set​(int row,
                      T value)
        Sets the value at index row to the given value and return this column
      • set

        default Column<T> set​(int row,
                              String stringValue,
                              AbstractColumnParser<?> parser)
        Sets the value at row to the parsed value of the given String using the given parser and returns this column
      • set

        Column<T> set​(int row,
                      Column<T> sourceColumn,
                      int sourceRow)
        Sets the value at row to the value at sourceRow in the given column and return this column
      • append

        Column<T> append​(T value)
        Appends value to the bottom of this column and return this column
      • append

        Column<T> append​(Column<T> column)
        Appends all the values in the argument to the bottom of this column and return this column
      • append

        Column<T> append​(Column<T> column,
                         int row)
        Appends the value at the given row in the given column to the bottom of this column and return this column
      • appendObj

        Column<T> appendObj​(Object value)
        Appends the given value to the bottom of this column and return this column
      • appendMissing

        Column<T> appendMissing()
        Appends a missing value appropriate to the column
      • valueHash

        int valueHash​(int rowNumber)
        Returns an int suitable as a hash for the value in this column at the given index
      • equals

        boolean equals​(int rowNumber1,
                       int rowNumber2)
        Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2
      • removeMissing

        Column<T> removeMissing()
        Returns a copy of this column with the missing values removed
      • unique

        Column<T> unique()
        Returns a column of the same type containing only the unique values
        Returns:
        a Column
      • first

        default Column<T> first​(int numRows)
        Returns a column of the same type containing the first numRows of this column.
      • last

        default Column<T> last​(int numRows)
        Returns a column of the same type containing the last numRows of this column.
      • setName

        Column<T> setName​(String name)
        Sets the columns name to the given string
        Parameters:
        name - The new name MUST be unique for any table containing this column
        Returns:
        this Column to allow method chaining
      • setParser

        Column<T> setParser​(AbstractColumnParser<T> parser)
        Sets the parser used by appendCell(String)
        Parameters:
        parser - a column parser that converts text input to the column data type
        Returns:
        this Column to allow method chaining
      • inRange

        default Column<T> inRange​(int start,
                                  int end)
        Returns a column containing the rows in this column beginning with start inclusive, and ending with end exclusive
      • sampleN

        default Column<T> sampleN​(int n)
        Returns a column containing a random sample of the values in this column
        Parameters:
        n - the number of values to select
        Returns:
        A column of the same type as the receiver
      • sampleX

        default Column<T> sampleX​(double proportion)
        Returns a table consisting of randomly selected values from this column. The sample size is based on the given proportion of the total number of cells in this column
        Parameters:
        proportion - The proportion to go in the sample
      • interpolate

        default Interpolator<T> interpolate()
        Provides the ability to create a new column with missing cells filled based off the value of nearby cells.
      • indexOf

        int indexOf​(Object o)
        Returns the index of the first occurrence of o in the column or -1 if the element is not in the column.
      • lastIndexOf

        int lastIndexOf​(Object o)
        Returns the index of the last occurrence of o in the column or -1 if the element is not in the column.