Class AbstractIntKeyMap<V>

java.lang.Object
zombie.util.map.AbstractIntKeyMap<V>
All Implemented Interfaces:
IntKeyMap<V>
Direct Known Subclasses:
IntKeyOpenHashMap

public abstract class AbstractIntKeyMap<V> extends Object implements IntKeyMap<V>
This class represents an abstract base for implementing maps from int values to objects. All operations that can be implemented using iterators are implemented as such. In most cases, this is hardly an efficient solution, and at least some of those methods should be overridden by sub-classes.
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears this map.
    boolean
    containsKey(int key)
    Indicates whether this map contains a mapping from a specified key.
    boolean
    Indicates whether this map contains a mapping to a specified value.
    boolean
    Indicates whether this map is equal to some object.
    get(int key)
    Maps a specified key to a value.
    int
    Returns a hash code value for this map.
    boolean
    Indicates whether this map is empty.
    void
    Adds all mappings from a specified map to this map.
    remove(int key)
    Removes the mapping from a specified key from this map.
    int
    Returns the size of this map.
    Returns a string representation of this map.
    void
    Does nothing.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface zombie.util.map.IntKeyMap

    entries, keySet, put, values
  • Method Details

    • clear

      public void clear()
      Description copied from interface: IntKeyMap
      Clears this map.
      Specified by:
      clear in interface IntKeyMap<V>
    • remove

      public V remove(int key)
      Description copied from interface: IntKeyMap
      Removes the mapping from a specified key from this map.
      Specified by:
      remove in interface IntKeyMap<V>
      Parameters:
      key - the key whose mapping to remove from this map.
      Returns:
      the old value (which can be null) if a mapping from the specified key already existed in this map; returns null otherwise.
    • putAll

      public void putAll(IntKeyMap<V> map)
      Description copied from interface: IntKeyMap
      Adds all mappings from a specified map to this map. Any existing mappings whose keys collide with a new mapping is overwritten by the new mapping.
      Specified by:
      putAll in interface IntKeyMap<V>
      Parameters:
      map - the map whose mappings to add to this map.
    • containsKey

      public boolean containsKey(int key)
      Description copied from interface: IntKeyMap
      Indicates whether this map contains a mapping from a specified key.
      Specified by:
      containsKey in interface IntKeyMap<V>
      Parameters:
      key - the key to test for.
      Returns:
      true if this map contains a mapping from the specified key; returns false otherwise.
    • get

      public V get(int key)
      Description copied from interface: IntKeyMap
      Maps a specified key to a value.
      Specified by:
      get in interface IntKeyMap<V>
      Parameters:
      key - the key to map to a value.
      Returns:
      the value that the specified key maps to; returns null, if no mapping exists for the specified key.
    • containsValue

      public boolean containsValue(Object value)
      Description copied from interface: IntKeyMap
      Indicates whether this map contains a mapping to a specified value.
      Specified by:
      containsValue in interface IntKeyMap<V>
      Parameters:
      value - the value to test for.
      Returns:
      true if this map contains at least one mapping to the specified value; returns false otherwise.
    • equals

      public boolean equals(Object obj)
      Description copied from interface: IntKeyMap
      Indicates whether this map is equal to some object.
      Specified by:
      equals in interface IntKeyMap<V>
      Overrides:
      equals in class Object
      Parameters:
      obj - the object with which to compare this map.
      Returns:
      true if this map is equal to the specified object; returns false otherwise.
    • hashCode

      public int hashCode()
      Description copied from interface: IntKeyMap
      Returns a hash code value for this map.
      Specified by:
      hashCode in interface IntKeyMap<V>
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this map.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: IntKeyMap
      Indicates whether this map is empty.
      Specified by:
      isEmpty in interface IntKeyMap<V>
      Returns:
      true if this map is empty; returns false otherwise.
    • size

      public int size()
      Description copied from interface: IntKeyMap
      Returns the size of this map. The size is defined as the number of mappings from keys to values.
      Specified by:
      size in interface IntKeyMap<V>
      Returns:
      the size of this map.
    • toString

      public String toString()
      Returns a string representation of this map.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this map.
    • trimToSize

      public void trimToSize()
      Does nothing. Sub-classes may provide an implementation to minimize memory usage, but this is not required since many implementations will always have minimal memory usage.