Interface Table<R,​C,​V>

  • Type Parameters:
    R - the row type parameter
    C - the column type parameter
    V - the value type parameter
    All Known Implementing Classes:
    HashBasedTable

    public interface Table<R,​C,​V>
    A table is a two dimensional structure that associates a value with two keys (i.e. a row and column key). A table maybe sparse, meaning not all cells contain values. Methods on a table that work with rows and columns return Map views that when updated will be reflected in table.
    Author:
    David B. Bracewell
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void clear()
      Clears the table.
      Map<R,​V> column​(C column)
      Returns a map view for a column in the table
      Set<C> columnKeySet()
      Returns a set of column keys that have one or more values associated
      boolean contains​(R row, C column)
      Checks if a value exists for a given row and column
      boolean containsColumn​(C column)
      Checks if column key exists in the table
      boolean containsRow​(R row)
      Checks if row key exists in the table
      Set<TableEntry<R,​C,​V>> entrySet()
      Gets the set of entries in the table
      V get​(R row, C column)
      Gets the value of the cell for the given row and column or null if not available.
      default V getOrDefault​(R row, C column, V defaultValue)  
      V put​(R row, C column, V value)
      Sets the value of the cell at the given row and column
      V remove​(R row, C column)
      Removes the value at the given cell.
      Map<R,​V> removeColumn​(C column)
      Removes a column from the table
      Map<C,​V> removeRow​(R row)
      Removes a row from the table
      Map<C,​V> row​(R row)
      Returns a map view for a row in the table
      Set<R> rowKeySet()
      Returns a set of row keys that have one or more values associated
      int size()
      The size in number of row and column mappings
      Collection<V> values()
      Collection of cell values in the table
    • Method Detail

      • clear

        void clear()
        Clears the table.
      • column

        Map<R,​V> column​(C column)
        Returns a map view for a column in the table
        Parameters:
        column - the column
        Returns:
        Map of row,value pairs
      • columnKeySet

        Set<C> columnKeySet()
        Returns a set of column keys that have one or more values associated
        Returns:
        the set of column keys that have one or more values associated
      • contains

        boolean contains​(R row,
                         C column)
        Checks if a value exists for a given row and column
        Parameters:
        row - the row
        column - the column
        Returns:
        True if it exists, False otherwise
      • containsColumn

        boolean containsColumn​(C column)
        Checks if column key exists in the table
        Parameters:
        column - the column
        Returns:
        True if it exists, False otherwise
      • containsRow

        boolean containsRow​(R row)
        Checks if row key exists in the table
        Parameters:
        row - the row
        Returns:
        True if it exists, False otherwise
      • entrySet

        Set<TableEntry<R,​C,​V>> entrySet()
        Gets the set of entries in the table
        Returns:
        the set of entries
      • get

        V get​(R row,
              C column)
        Gets the value of the cell for the given row and column or null if not available.
        Parameters:
        row - the row
        column - the column
        Returns:
        the value of the cell at the given row and column or null
      • getOrDefault

        default V getOrDefault​(R row,
                               C column,
                               V defaultValue)
      • put

        V put​(R row,
              C column,
              V value)
        Sets the value of the cell at the given row and column
        Parameters:
        row - the row
        column - the column
        value - the value
        Returns:
        the previous value
      • remove

        V remove​(R row,
                 C column)
        Removes the value at the given cell.
        Parameters:
        row - the row
        column - the column
        Returns:
        the value of the cell
      • removeColumn

        Map<R,​V> removeColumn​(C column)
        Removes a column from the table
        Parameters:
        column - the column
        Returns:
        Map containing row, value pairs
      • removeRow

        Map<C,​V> removeRow​(R row)
        Removes a row from the table
        Parameters:
        row - the row
        Returns:
        Map containing column, value pairs
      • row

        Map<C,​V> row​(R row)
        Returns a map view for a row in the table
        Parameters:
        row - the row
        Returns:
        Map of column,value pairs
      • rowKeySet

        Set<R> rowKeySet()
        Returns a set of row keys that have one or more values associated
        Returns:
        the set of row keys that have one or more values associated
      • size

        int size()
        The size in number of row and column mappings
        Returns:
        number of row and column mappings
      • values

        Collection<V> values()
        Collection of cell values in the table
        Returns:
        the collection of cell values in the table