Class HashBasedTable<R,​C,​V>

  • Type Parameters:
    R - the row type parameter
    C - the column type parameter
    V - the value type parameter
    All Implemented Interfaces:
    Table<R,​C,​V>, Serializable

    public class HashBasedTable<R,​C,​V>
    extends Object
    implements Table<R,​C,​V>, Serializable
    Table implementation using a map of maps.
    Author:
    David B. Bracewell
    See Also:
    Serialized Form
    • Constructor Detail

      • HashBasedTable

        protected HashBasedTable​(List<TableEntry<R,​C,​V>> entryList)
    • Method Detail

      • clear

        public void clear()
        Description copied from interface: Table
        Clears the table.
        Specified by:
        clear in interface Table<R,​C,​V>
      • column

        public Map<R,​V> column​(C column)
        Description copied from interface: Table
        Returns a map view for a column in the table
        Specified by:
        column in interface Table<R,​C,​V>
        Parameters:
        column - the column
        Returns:
        Map of row,value pairs
      • columnKeySet

        public Set<C> columnKeySet()
        Description copied from interface: Table
        Returns a set of column keys that have one or more values associated
        Specified by:
        columnKeySet in interface Table<R,​C,​V>
        Returns:
        the set of column keys that have one or more values associated
      • contains

        public boolean contains​(R row,
                                C column)
        Description copied from interface: Table
        Checks if a value exists for a given row and column
        Specified by:
        contains in interface Table<R,​C,​V>
        Parameters:
        row - the row
        column - the column
        Returns:
        True if it exists, False otherwise
      • containsColumn

        public boolean containsColumn​(C column)
        Description copied from interface: Table
        Checks if column key exists in the table
        Specified by:
        containsColumn in interface Table<R,​C,​V>
        Parameters:
        column - the column
        Returns:
        True if it exists, False otherwise
      • containsRow

        public boolean containsRow​(R row)
        Description copied from interface: Table
        Checks if row key exists in the table
        Specified by:
        containsRow in interface Table<R,​C,​V>
        Parameters:
        row - the row
        Returns:
        True if it exists, False otherwise
      • entrySet

        public Set<TableEntry<R,​C,​V>> entrySet()
        Description copied from interface: Table
        Gets the set of entries in the table
        Specified by:
        entrySet in interface Table<R,​C,​V>
        Returns:
        the set of entries
      • get

        public V get​(R row,
                     C column)
        Description copied from interface: Table
        Gets the value of the cell for the given row and column or null if not available.
        Specified by:
        get in interface Table<R,​C,​V>
        Parameters:
        row - the row
        column - the column
        Returns:
        the value of the cell at the given row and column or null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • put

        public V put​(R row,
                     C column,
                     V value)
        Description copied from interface: Table
        Sets the value of the cell at the given row and column
        Specified by:
        put in interface Table<R,​C,​V>
        Parameters:
        row - the row
        column - the column
        value - the value
        Returns:
        the previous value
      • remove

        public V remove​(R row,
                        C column)
        Description copied from interface: Table
        Removes the value at the given cell.
        Specified by:
        remove in interface Table<R,​C,​V>
        Parameters:
        row - the row
        column - the column
        Returns:
        the value of the cell
      • removeColumn

        public Map<R,​V> removeColumn​(C column)
        Description copied from interface: Table
        Removes a column from the table
        Specified by:
        removeColumn in interface Table<R,​C,​V>
        Parameters:
        column - the column
        Returns:
        Map containing row, value pairs
      • removeRow

        public Map<C,​V> removeRow​(R row)
        Description copied from interface: Table
        Removes a row from the table
        Specified by:
        removeRow in interface Table<R,​C,​V>
        Parameters:
        row - the row
        Returns:
        Map containing column, value pairs
      • row

        public Map<C,​V> row​(R row)
        Description copied from interface: Table
        Returns a map view for a row in the table
        Specified by:
        row in interface Table<R,​C,​V>
        Parameters:
        row - the row
        Returns:
        Map of column,value pairs
      • rowKeySet

        public Set<R> rowKeySet()
        Description copied from interface: Table
        Returns a set of row keys that have one or more values associated
        Specified by:
        rowKeySet in interface Table<R,​C,​V>
        Returns:
        the set of row keys that have one or more values associated
      • size

        public int size()
        Description copied from interface: Table
        The size in number of row and column mappings
        Specified by:
        size in interface Table<R,​C,​V>
        Returns:
        number of row and column mappings
      • values

        public Collection<V> values()
        Description copied from interface: Table
        Collection of cell values in the table
        Specified by:
        values in interface Table<R,​C,​V>
        Returns:
        the collection of cell values in the table