Class IntMap<T>

  • All Implemented Interfaces:
    java.lang.Cloneable

    public final class IntMap<T>
    extends java.lang.Object
    implements java.lang.Cloneable
    An efficient object map whose keys are objects and whose values are ints.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int count  
      private java.lang.Object[] keys  
      private int resizeCount  
      private int[] values  
    • Constructor Summary

      Constructors 
      Constructor Description
      IntMap()
      Construct a new instance with an initial capacity of 64 and a load factor of 0.5.
      IntMap​(float loadFactor)
      Construct a new instance with the given load factor and an initial capacity of 64.
      IntMap​(int initialCapacity)
      Construct a new instance with the given initial capacity and a load factor of 0.5.
      IntMap​(int initialCapacity, float loadFactor)
      Construct a new instance with the given initial capacity and load factor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      IntMap<T> clone()
      Clone this map.
      int get​(T key, int defVal)
      Get a value from the map.
      void put​(T key, int value)
      Put a value into the map.
      private void resize()  
      java.lang.String toString()
      Get a string summary representation of this map.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • values

        private int[] values
      • keys

        private java.lang.Object[] keys
      • count

        private int count
      • resizeCount

        private int resizeCount
    • Constructor Detail

      • IntMap

        public IntMap​(int initialCapacity,
                      float loadFactor)
        Construct a new instance with the given initial capacity and load factor.
        Parameters:
        initialCapacity - the initial capacity
        loadFactor - the load factor
      • IntMap

        public IntMap​(float loadFactor)
        Construct a new instance with the given load factor and an initial capacity of 64.
        Parameters:
        loadFactor - the load factor
      • IntMap

        public IntMap​(int initialCapacity)
        Construct a new instance with the given initial capacity and a load factor of 0.5.
        Parameters:
        initialCapacity - the initial capacity
      • IntMap

        public IntMap()
        Construct a new instance with an initial capacity of 64 and a load factor of 0.5.
    • Method Detail

      • clone

        public IntMap<T> clone()
        Clone this map.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a cloned map
      • get

        public int get​(T key,
                       int defVal)
        Get a value from the map.
        Parameters:
        key - the key
        defVal - the value to return if the key is not found
        Returns:
        the map value at the given key, or the value of defVal if it's not found
      • put

        public void put​(T key,
                        int value)
        Put a value into the map. Any previous mapping is discarded silently.
        Parameters:
        key - the key
        value - the value to store
      • resize

        private void resize()
      • clear

        public void clear()
      • toString

        public java.lang.String toString()
        Get a string summary representation of this map.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation