Class IntToIntHashMap

java.lang.Object
net.sf.saxon.z.IntToIntHashMap
All Implemented Interfaces:
IntToIntMap

public class IntToIntHashMap extends Object implements IntToIntMap
A hash table that maps int keys to int values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a map with a capacity of 8 and a load factor of 0,25.
    IntToIntHashMap(int capacity)
    Initializes a map with the given capacity and a load factor of 0,25.
    IntToIntHashMap(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.
    boolean
    contains(int key)
    Finds a key in the map.
    int
    get(int key)
    Gets the value for this key.
    int
    Get the default value used to indicate an unused entry
    Get an iterator over the integer key values held in the hash map
    void
    put(int key, int value)
    Adds a key-value pair to the map.
    boolean
    remove(int key)
    Removes a key from the map.
    void
    setDefaultValue(int defaultValue)
    Set the value to be returned to indicate an unused entry
    int
    Gets the size of the map.
    The toString() method on this class is designed for diagnostics only, and the output should not be regarded as stable between releases.

    Methods inherited from class java.lang.Object

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

    • IntToIntHashMap

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

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

      public IntToIntHashMap(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

    • setDefaultValue

      public void setDefaultValue(int defaultValue)
      Set the value to be returned to indicate an unused entry
      Specified by:
      setDefaultValue in interface IntToIntMap
      Parameters:
      defaultValue - the value to be returned by get(int) if no entry exists for the supplied key
    • getDefaultValue

      public int getDefaultValue()
      Get the default value used to indicate an unused entry
      Specified by:
      getDefaultValue in interface IntToIntMap
      Returns:
      the value to be returned by get(int) if no entry exists for the supplied key
    • clear

      public void clear()
      Clears the map.
      Specified by:
      clear in interface IntToIntMap
    • contains

      public boolean contains(int key)
      Finds a key in the map.
      Specified by:
      contains in interface IntToIntMap
      Parameters:
      key - Key
      Returns:
      true if the key is mapped
    • get

      public int get(int key)
      Gets the value for this key.
      Specified by:
      get in interface IntToIntMap
      Parameters:
      key - Key
      Returns:
      the value, or the default value if not found.
    • size

      public int size()
      Gets the size of the map.
      Specified by:
      size in interface IntToIntMap
      Returns:
      the size
    • remove

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

      public void put(int key, int value)
      Adds a key-value pair to the map.
      Specified by:
      put in interface IntToIntMap
      Parameters:
      key - Key
      value - Value
    • keyIterator

      public IntIterator keyIterator()
      Get an iterator over the integer key values held in the hash map
      Specified by:
      keyIterator in interface IntToIntMap
      Returns:
      an iterator whose next() call returns the key values (in arbitrary order)
    • toString

      public String toString()
      The toString() method on this class is designed for diagnostics only, and the output should not be regarded as stable between releases. Up to 100 key-value pairs are output in the format key:value, with comma separators, enclosed between braces: for example "{1:100,2:200}".
      Overrides:
      toString in class Object
      Returns:
      A string representation of some of the key-value pairs