IntToIntMap (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.language.util

## Class IntToIntMap

- java.lang.Object
- - hlt.language.util.ToIntMap
  - - hlt.language.util.IntToIntMap

-     public class IntToIntMap
      extends ToIntMap

  This is a class of hash tables mapping ints to ints.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `IntToIntMap.Entry` The class defining the map entries.

  - ### Field Summary

    - ### Fields inherited from class hlt.language.util.ToIntMap

      `NOT_FOUND_VALUE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IntToIntMap()` Constructs a new empty map with a default capacity of `11`.
    `IntToIntMap(int initialCapacity)` Constructs a new empty map with the specified initial capacity and a default load factor equal to `0.75`.
    `IntToIntMap(int initialCapacity, float loadFactor)` Constructs a new empty map with the specified initial capacity and load factor.
    `IntToIntMap(IntToIntMap map)` Constructs a new map with the same entries as the given map.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `add(int n)` Associates the current size of the map to the given int, and returns this value.
    `boolean` | `containsEntry(int key, int value)` Returns `true` if this map contains an entry with the specified key and value.
    `boolean` | `containsEntry(ToIntMap.Entry candidate)` Returns `true` if this map contains the specified entry.
    `boolean` | `containsKey(int key)` Returns `true` if this map contains an entry for the specified key.
    `boolean` | `equals(java.lang.Object object)` Compares the specified object with this map for equality.
    `int` | `get(int key)` Returns the value to which this map maps the specified key.
    `IntIterator` | `keys()` Returns an iterator through the keys of this map.
    `int` | `put(int key, int value)` Associates the specified value with the specified key in this map.
    `int` | `put(ToIntMap.Entry entry)` Puts the mapping defined by the specified entry into this map.
    `int` | `remove(int key)` Removes the entry for the given key from this map if present.
    `IntIterator` | `values()` Returns an iterator through the values of this map.

    - ### Methods inherited from class hlt.language.util.ToIntMap

      `clear, containsValue, hashCode, include, isEmpty, isEqualTo, iterator, size, toString`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### IntToIntMap

          public IntToIntMap()

      Constructs a new empty map with a default capacity of `11`.

    - #### IntToIntMap

          public IntToIntMap(int initialCapacity)

      Constructs a new empty map with the specified initial capacity and a default load factor equal to `0.75`.
      Parameters:
        `initialCapacity` - the initial capacity of the map
      Throws:
        `java.lang.IllegalArgumentException` - if the initial capacity is negative.

    - #### IntToIntMap

          public IntToIntMap(int initialCapacity,
                     float loadFactor)

      Constructs a new empty map with the specified initial capacity and load factor. If the load factor is greater than `1`, it is reset to 1 (which means that the map is enlarged only when all the table's indices are occupied - generally a bad idea).
      Parameters:
        `initialCapacity` - the initial capacity of the map
        `loadFactor` - the load factor of the map
      Throws:
        `java.lang.IllegalArgumentException` - if either argument is negative.

    - #### IntToIntMap

          public IntToIntMap(IntToIntMap map)

      Constructs a new map with the same entries as the given map. The map is created with a capacity of twice the number of entries in the given map or 11 (whichever is greater), and a default load factor, which is `0.75`.
      Parameters:
        `map` - the `IntToIntMap` whose entries are to be placed in this map.

  - ### Method Detail

    - #### containsKey

          public final boolean containsKey(int key)

      Returns `true` if this map contains an entry for the specified key.
      Parameters:
        `key` - the key whose presence in this map is to be tested.

    - #### containsEntry

          public final boolean containsEntry(int key,
                              int value)

      Returns `true` if this map contains an entry with the specified key and value.
      Parameters:
        `key` - the key
        `value` - the value

    - #### containsEntry

          public final boolean containsEntry(ToIntMap.Entry candidate)

      Returns `true` if this map contains the specified entry.
      Specified by:
        `containsEntry` in class `ToIntMap`
      Parameters:
        `candidate` - the entry whose presence in this map is to be tested.

    - #### get

          public final int get(int key)

      Returns the value to which this map maps the specified key. Returns `NOT_FOUND_VALUE` if the map contains no entry for this key. The value `NOT_FOUND_VALUE` is defined as `Integer.MIN_VALUE` (which is equal to `-2147483648`). Therefore, a return value equal to ``NOT_FOUND_VALUE`` does not necessarily indicate that the map contains no entry for the key; it's also possible that the map explicitly maps the key to `-2147483648`. In this case, the `containsKey` operation may be used to distinguish these two cases.
      Parameters:
        `key` - the key whose associated value is to be returned.

    - #### add

          public final int add(int n)

      Associates the current size of the map to the given int, and returns this value.

    - #### put

          public final int put(int key,
                int value)

      Associates the specified value with the specified key in this map. If the map previously contained an entry for this key, the old value is replaced and returned; otherwise the new value is returned. The map is automatically enlarged if its size exceeds its threshold.
      Parameters:
        `key` - key with which the specified value is to be associated.
        `value` - value to be associated with the specified key.

    - #### remove

          public final int remove(int key)

      Removes the entry for the given key from this map if present. Returns the previous value associated with the specified key, or `NOT_FOUND_VALUE` if there was no entry for the key. A returned `NOT_FOUND_VALUE` may also indicate that the map previously associated `NOT_FOUND_VALUE` with the specified key.
      Parameters:
        `key` - key whose entry is to be removed from the map.

    - #### put

          public final int put(ToIntMap.Entry entry)

      Puts the mapping defined by the specified entry into this map. Returns the old value if one was there, or the new value.
      Specified by:
        `put` in class `ToIntMap`
      Parameters:
        `entry` - the entry whose mapping is to be put into this map.

    - #### keys

          public final IntIterator keys()

      Returns an iterator through the keys of this map. The value returned by its `next()` method is an int.

    - #### values

          public final IntIterator values()

      Returns an iterator through the values of this map. The value returned by its `next()` method is an int.
      Specified by:
        `values` in class `ToIntMap`

    - #### equals

          public final boolean equals(java.lang.Object object)

      Compares the specified object with this map for equality. Returns `true` if the given object is also a map and the two maps have equal entries.
      Overrides:
        `equals` in class `ToIntMap`
      Parameters:
        `object` - object to be compared for equality with this map.