Class AbstractTable<R,C,V>

java.lang.Object
com.google.common.collect.AbstractTable<R,C,V>
All Implemented Interfaces:
Table<R,C,V>
Direct Known Subclasses:
ArrayTable, ImmutableTable, StandardTable, Tables.TransformedTable, Tables.TransposeTable

abstract class AbstractTable<R,C,V> extends Object implements Table<R,C,V>
Skeletal, implementation-agnostic implementation of the Table interface.
  • Field Details

    • cellSet

      @CheckForNull private transient Set<Table.Cell<R,C,V>> cellSet
    • values

      @CheckForNull private transient Collection<V> values
  • Constructor Details

    • AbstractTable

      AbstractTable()
  • Method Details

    • containsRow

      public boolean containsRow(@CheckForNull Object rowKey)
      Description copied from interface: Table
      Returns true if the table contains a mapping with the specified row key.
      Specified by:
      containsRow in interface Table<R,C,V>
      Parameters:
      rowKey - key of row to search for
    • containsColumn

      public boolean containsColumn(@CheckForNull Object columnKey)
      Description copied from interface: Table
      Returns true if the table contains a mapping with the specified column.
      Specified by:
      containsColumn in interface Table<R,C,V>
      Parameters:
      columnKey - key of column to search for
    • rowKeySet

      public Set<R> rowKeySet()
      Description copied from interface: Table
      Returns a set of row keys that have one or more values in the table. Changes to the set will update the underlying table, and vice versa.
      Specified by:
      rowKeySet in interface Table<R,C,V>
      Returns:
      set of row keys
    • columnKeySet

      public Set<C> columnKeySet()
      Description copied from interface: Table
      Returns a set of column keys that have one or more values in the table. Changes to the set will update the underlying table, and vice versa.
      Specified by:
      columnKeySet in interface Table<R,C,V>
      Returns:
      set of column keys
    • containsValue

      public boolean containsValue(@CheckForNull Object value)
      Description copied from interface: Table
      Returns true if the table contains a mapping with the specified value.
      Specified by:
      containsValue in interface Table<R,C,V>
      Parameters:
      value - value to search for
    • contains

      public boolean contains(@CheckForNull Object rowKey, @CheckForNull Object columnKey)
      Description copied from interface: Table
      Returns true if the table contains a mapping with the specified row and column keys.
      Specified by:
      contains in interface Table<R,C,V>
      Parameters:
      rowKey - key of row to search for
      columnKey - key of column to search for
    • get

      @CheckForNull public V get(@CheckForNull Object rowKey, @CheckForNull Object columnKey)
      Description copied from interface: Table
      Returns the value corresponding to the given row and column keys, or null if no such mapping exists.
      Specified by:
      get in interface Table<R,C,V>
      Parameters:
      rowKey - key of row to search for
      columnKey - key of column to search for
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Table
      Returns true if the table contains no mappings.
      Specified by:
      isEmpty in interface Table<R,C,V>
    • clear

      public void clear()
      Description copied from interface: Table
      Removes all mappings from the table.
      Specified by:
      clear in interface Table<R,C,V>
    • remove

      @CheckForNull public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey)
      Description copied from interface: Table
      Removes the mapping, if any, associated with the given keys.
      Specified by:
      remove in interface Table<R,C,V>
      Parameters:
      rowKey - row key of mapping to be removed
      columnKey - column key of mapping to be removed
      Returns:
      the value previously associated with the keys, or null if no such value existed
    • put

      @CheckForNull public V put(R rowKey, C columnKey, V value)
      Description copied from interface: Table
      Associates the specified value with the specified keys. If the table already contained a mapping for those keys, the old value is replaced with the specified value.
      Specified by:
      put in interface Table<R,C,V>
      Parameters:
      rowKey - row key that the value should be associated with
      columnKey - column key that the value should be associated with
      value - value to be associated with the specified keys
      Returns:
      the value previously associated with the keys, or null if no mapping existed for the keys
    • putAll

      public void putAll(Table<? extends R,? extends C,? extends V> table)
      Description copied from interface: Table
      Copies all mappings from the specified table to this table. The effect is equivalent to calling Table.put(R, C, V) with each row key / column key / value mapping in table.
      Specified by:
      putAll in interface Table<R,C,V>
      Parameters:
      table - the table to add to this table
    • cellSet

      public Set<Table.Cell<R,C,V>> cellSet()
      Description copied from interface: Table
      Returns a set of all row key / column key / value triplets. Changes to the returned set will update the underlying table, and vice versa. The cell set does not support the add or addAll methods.
      Specified by:
      cellSet in interface Table<R,C,V>
      Returns:
      set of table cells consisting of row key / column key / value triplets
    • createCellSet

      Set<Table.Cell<R,C,V>> createCellSet()
    • cellIterator

      abstract Iterator<Table.Cell<R,C,V>> cellIterator()
    • cellSpliterator

      abstract Spliterator<Table.Cell<R,C,V>> cellSpliterator()
    • values

      public Collection<V> values()
      Description copied from interface: Table
      Returns a collection of all values, which may contain duplicates. Changes to the returned collection will update the underlying table, and vice versa.
      Specified by:
      values in interface Table<R,C,V>
      Returns:
      collection of values
    • createValues

      Collection<V> createValues()
    • valuesIterator

      Iterator<V> valuesIterator()
    • valuesSpliterator

      Spliterator<V> valuesSpliterator()
    • equals

      public boolean equals(@CheckForNull Object obj)
      Description copied from interface: Table
      Compares the specified object with this table for equality. Two tables are equal when their cell views, as returned by Table.cellSet(), are equal.
      Specified by:
      equals in interface Table<R,C,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Description copied from interface: Table
      Returns the hash code for this table. The hash code of a table is defined as the hash code of its cell view, as returned by Table.cellSet().
      Specified by:
      hashCode in interface Table<R,C,V>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns the string representation rowMap().toString().
      Overrides:
      toString in class Object