Class Object2IntArrayMap<K>

All Implemented Interfaces:
Function<K,Integer>, Object2IntFunction<K>, Object2IntMap<K>, Serializable, Cloneable, Function<K,Integer>, ToIntFunction<K>, Map<K,Integer>

public class Object2IntArrayMap<K> extends AbstractObject2IntMap<K> implements Serializable, Cloneable
A simple, brute-force implementation of a map based on two parallel backing arrays.

The main purpose of this implementation is that of wrapping cleanly the brute-force approach to the storage of a very small number of pairs: just put them into two parallel arrays and scan linearly to find an item.

See Also:
  • Constructor Details

    • Object2IntArrayMap

      public Object2IntArrayMap(Object[] key, int[] value)
      Creates a new empty array map with given key and value backing arrays. The resulting map will have as many entries as the given arrays.

      It is responsibility of the caller that the elements of key are distinct.

      Parameters:
      key - the key array.
      value - the value array (it must have the same length as key).
    • Object2IntArrayMap

      public Object2IntArrayMap()
      Creates a new empty array map.
    • Object2IntArrayMap

      public Object2IntArrayMap(int capacity)
      Creates a new empty array map of given capacity.
      Parameters:
      capacity - the initial capacity.
    • Object2IntArrayMap

      public Object2IntArrayMap(Object2IntMap<K> m)
      Creates a new empty array map copying the entries of a given map.
      Parameters:
      m - a map.
    • Object2IntArrayMap

      public Object2IntArrayMap(Map<? extends K,? extends Integer> m)
      Creates a new empty array map copying the entries of a given map.
      Parameters:
      m - a map.
    • Object2IntArrayMap

      public Object2IntArrayMap(Object[] key, int[] value, int size)
      Creates a new array map with given key and value backing arrays, using the given number of elements.

      It is responsibility of the caller that the first size elements of key are distinct.

      Parameters:
      key - the key array.
      value - the value array (it must have the same length as key).
      size - the number of valid elements in key and value.
  • Method Details