Class AbstractMap<K,V>

java.lang.Object
com.zybooks.dsaj.map.AbstractMap<K,V>
Type Parameters:
K - The key type (keys must be unique)
V - The value type
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
AbstractHashMap, AbstractSortedMap, UnsortedTableMap

public abstract class AbstractMap<K,V> extends Object implements Map<K,V>
An abstract base class to ease the implementation of the Map interface. The base class provides three means of support: 1) It defines a protected MapEntry class as a concrete implementation of the entry interface 2) It provides an isEmpty implementation based upon the abstract size() method. 3) It provides implemenations of the keySet and values methods, based upon use of a presumed implementation of the entrySet method.
  • Constructor Details

    • AbstractMap

      public AbstractMap()
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Tests whether the map is empty.
      Specified by:
      isEmpty in interface Map<K,V>
      Returns:
      true if the map is empty, false otherwise
    • keySet

      public Iterable<K> keySet()
      Returns an iterable collection of the keys contained in the map.
      Specified by:
      keySet in interface Map<K,V>
      Returns:
      iterable collection of the map's keys
    • values

      public Iterable<V> values()
      Returns an iterable collection of the values contained in the map. Note that the same value will be given multiple times in the result if it is associated with multiple keys.
      Specified by:
      values in interface Map<K,V>
      Returns:
      iterable collection of the map's values