Class HashMapIntLong

java.lang.Object
org.eclipse.mat.collect.HashMapIntLong
All Implemented Interfaces:
Serializable

public final class HashMapIntLong extends Object implements Serializable
A map from int to long. More efficient than a general map
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    An entry from the map
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a map of default size
    HashMapIntLong(int initialCapacity)
    Create a map of given size
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Remove all the existing mappings, leaving the capacity unchanged.
    boolean
    containsKey(int key)
    find if key is present in map
    Iterate over all the map entries
    long
    get(int key)
    Retrieve the value corresponding to the key
    int[]
    Get all the used keys
    long[]
    Get all the values corresponding to the used keys.
    boolean
    Is the map empty
    Get a way of iterating over the keys
    boolean
    put(int key, long value)
    Add a mapping
    boolean
    remove(int key)
    Remove an mapping from the map
    int
    The number of mappings
    Get a way of iterating over the values.

    Methods inherited from class java.lang.Object

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

    • HashMapIntLong

      public HashMapIntLong()
      Create a map of default size
    • HashMapIntLong

      public HashMapIntLong(int initialCapacity)
      Create a map of given size
      Parameters:
      initialCapacity - in entries.
  • Method Details

    • put

      public boolean put(int key, long value)
      Add a mapping
      Parameters:
      key - the key
      value - the corresponding value
      Returns:
      true if an entry with the key already exists
    • remove

      public boolean remove(int key)
      Remove an mapping from the map
      Parameters:
      key - the key to remove
      Returns:
      true if entry was found
    • containsKey

      public boolean containsKey(int key)
      find if key is present in map
      Parameters:
      key - the key
      Returns:
      true if the key was found
    • get

      public long get(int key)
      Retrieve the value corresponding to the key
      Parameters:
      key - the key
      Returns:
      the value
      Throws:
      NoSuchElementException - if the key is not found
    • getAllKeys

      public int[] getAllKeys()
      Get all the used keys
      Returns:
      an array of the used keys
    • size

      public int size()
      The number of mappings
      Returns:
      the size of the map
    • isEmpty

      public boolean isEmpty()
      Is the map empty
      Returns:
      true if no current mappings
    • clear

      public void clear()
      Remove all the existing mappings, leaving the capacity unchanged.
    • keys

      public IteratorInt keys()
      Get a way of iterating over the keys
      Returns:
      an iterator over the keys
    • values

      public IteratorLong values()
      Get a way of iterating over the values.
      Returns:
      an iterator over the values
    • entries

      public Iterator<HashMapIntLong.Entry> entries()
      Iterate over all the map entries
      Returns:
      the iterator over the entries
    • getAllValues

      public long[] getAllValues()
      Get all the values corresponding to the used keys. Duplicate values are possible if they correspond to different keys.
      Returns:
      an array of the used values