Class KeyMap<K extends KeyMap.HashItem>

java.lang.Object
org.oscim.utils.pool.Inlist<KeyMap<K>>
org.oscim.utils.KeyMap<K>
Type Parameters:
K - the type of keys maintained by this map

public class KeyMap<K extends KeyMap.HashItem> extends Inlist<KeyMap<K>>

Note: the implementation of KeyMap is not synchronized. If one thread of several threads accessing an instance modifies the map structurally, access to the map needs to be synchronized. A structural modification is an operation that adds or removes an entry. Changes in the value of an entry are not structural changes.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    Nested classes/interfaces inherited from class org.oscim.utils.pool.Inlist

    Inlist.List<T extends Inlist<?>>
  • Field Summary

    Fields inherited from class org.oscim.utils.pool.Inlist

    next
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new empty HashMap instance.
    KeyMap(int capacity)
    Constructs a new HashMap instance with the specified capacity.
    KeyMap(int capacity, float loadFactor)
    Constructs a new HashMap instance with the specified capacity and load factor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all mappings from this hash map, leaving it empty.
    Returns the value of the mapping with the specified key.
    boolean
    Returns whether this map is empty.
    put(K key)
    Maps the specified key to the specified value.
    put(K key, boolean replace)
     
     
    remove(K key)
    Removes the mapping with the specified key from this map.
    int
    Returns the number of elements in this map.

    Methods inherited from class org.oscim.utils.pool.Inlist

    appendItem, appendList, get, last, next, prependRelative, push, remove, size

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KeyMap

      public KeyMap()
      Constructs a new empty HashMap instance.
    • KeyMap

      public KeyMap(int capacity)
      Constructs a new HashMap instance with the specified capacity.
      Parameters:
      capacity - the initial capacity of this hash map.
      Throws:
      IllegalArgumentException - when the capacity is less than zero.
    • KeyMap

      public KeyMap(int capacity, float loadFactor)
      Constructs a new HashMap instance with the specified capacity and load factor.
      Parameters:
      capacity - the initial capacity of this hash map.
      loadFactor - the initial load factor.
      Throws:
      IllegalArgumentException - when the capacity is less than zero or the load factor is less or equal to zero or NaN.
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns whether this map is empty.
      Returns:
      true if this map has no elements, false otherwise.
      See Also:
    • size

      public int size()
      Returns the number of elements in this map.
      Returns:
      the number of elements in this map.
    • get

      public K get(KeyMap.HashItem key)
      Returns the value of the mapping with the specified key.
      Parameters:
      key - the key.
      Returns:
      the value of the mapping with the specified key, or null if no mapping for the specified key is found.
    • put

      public K put(K key)
      Maps the specified key to the specified value.
      Parameters:
      key - the key.
      value - the value.
      Returns:
      the value of any previous mapping with the specified key or null if there was no such mapping.
    • put

      public K put(K key, boolean replace)
    • remove

      public K remove(K key)
      Removes the mapping with the specified key from this map.
      Parameters:
      key - the key of the mapping to remove.
      Returns:
      the value of the removed mapping or null if no mapping for the specified key was found.
    • clear

      public void clear()
      Removes all mappings from this hash map, leaving it empty.
      See Also:
    • releaseItems

      public K releaseItems()