Class IntHashMap

java.lang.Object
net.sf.saxon.sort.IntHashMap
All Implemented Interfaces:
Serializable

public class IntHashMap extends Object implements Serializable
A hash table that maps int keys to Object values.
Author:
Dave Hale, Landmark Graphics, Dominique Devienne, Michael Kay: retrofitted to JDK 1.4, added iterator(), modified to disallow null values
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a map with a capacity of 8 and a load factor of 0,25.
    IntHashMap(int capacity)
    Initializes a map with the given capacity and a load factor of 0,25.
    IntHashMap(int capacity, double factor)
    Constructs a new map with initial capacity, and load factor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the map.
    Create a copy of the IntHashMap
    void
    Diagnostic display of contents
    get(int key)
    Gets the value for this key.
    Get an iterator over the keys
    void
    put(int key, Object value)
    Adds a key-value pair to the map.
    boolean
    remove(int key)
    Removes a key from the map.
    int
    Gets the size of the map.
    Get an iterator over the values

    Methods inherited from class java.lang.Object

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

    • IntHashMap

      public IntHashMap()
      Initializes a map with a capacity of 8 and a load factor of 0,25.
    • IntHashMap

      public IntHashMap(int capacity)
      Initializes a map with the given capacity and a load factor of 0,25.
      Parameters:
      capacity - the initial capacity.
    • IntHashMap

      public IntHashMap(int capacity, double factor)
      Constructs a new map with initial capacity, and load factor.

      The capacity is the number of keys that can be mapped without resizing the arrays in which keys and values are stored. For efficiency, only a fraction of the elements in those arrays are used. That fraction is the specified load factor. The initial length of the arrays equals the smallest power of two not less than the ratio capacity/factor. The capacity of the map is increased, as necessary. The maximum number of keys that can be mapped is 2^30.

      Parameters:
      capacity - the initial capacity.
      factor - the load factor.
  • Method Details

    • clear

      public void clear()
      Clears the map.
    • get

      public Object get(int key)
      Gets the value for this key.
      Parameters:
      key - Key
      Returns:
      the value, null if not found.
    • size

      public int size()
      Gets the size of the map.
      Returns:
      the size (the number of entries in the map)
    • remove

      public boolean remove(int key)
      Removes a key from the map.
      Parameters:
      key - Key to remove
      Returns:
      true if the value was removed
    • put

      public void put(int key, Object value)
      Adds a key-value pair to the map.
      Parameters:
      key - Key
      value - Value
    • keyIterator

      public IntIterator keyIterator()
      Get an iterator over the keys
    • valueIterator

      public Iterator valueIterator()
      Get an iterator over the values
    • copy

      public IntHashMap copy()
      Create a copy of the IntHashMap
    • display

      public void display()
      Diagnostic display of contents