Class IntTable

  • All Implemented Interfaces:
    java.io.Serializable

    public class IntTable
    extends java.lang.Object
    implements java.io.Serializable
    A simple hashtable, not synchronized, with fixed load factor, that maps objects to ints. This implementation is not Thread-safe.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  IntTable.Entry
      To manage collisions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int count
      The number of entries
      protected static int INITIAL_CAPACITY
      The initial capacity
      protected IntTable.Entry[] table
      The underlying array
    • Constructor Summary

      Constructors 
      Constructor Description
      IntTable()
      Creates a new table.
      IntTable​(int c)
      Creates a new table.
      IntTable​(IntTable t)
      Creates a copy of the given HashTable object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears the table.
      int dec​(java.lang.Object key)
      Decrements the value associated with the given key.
      protected IntTable.Entry find​(java.lang.Object key)
      Finds the Entry with the given key.
      int get​(java.lang.Object key)
      Returns the value associated with the given key.
      int inc​(java.lang.Object key)
      Increments the value associated with the given key.
      int put​(java.lang.Object key, int value)
      Sets the value associated with the given key.
      protected void rehash()
      Rehashes the table.
      int remove​(java.lang.Object key)
      Removes an entry from the table.
      int size()
      Returns the size of this table.
      • Methods inherited from class java.lang.Object

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

      • INITIAL_CAPACITY

        protected static final int INITIAL_CAPACITY
        The initial capacity
        See Also:
        Constant Field Values
      • count

        protected int count
        The number of entries
    • Constructor Detail

      • IntTable

        public IntTable()
        Creates a new table.
      • IntTable

        public IntTable​(int c)
        Creates a new table.
        Parameters:
        c - The initial capacity.
      • IntTable

        public IntTable​(IntTable t)
        Creates a copy of the given HashTable object.
        Parameters:
        t - The table to copy.
    • Method Detail

      • size

        public int size()
        Returns the size of this table.
      • find

        protected IntTable.Entry find​(java.lang.Object key)
        Finds the Entry with the given key.
      • get

        public int get​(java.lang.Object key)
        Returns the value associated with the given key.
      • put

        public int put​(java.lang.Object key,
                       int value)
        Sets the value associated with the given key.
      • inc

        public int inc​(java.lang.Object key)
        Increments the value associated with the given key.
      • dec

        public int dec​(java.lang.Object key)
        Decrements the value associated with the given key.
      • remove

        public int remove​(java.lang.Object key)
        Removes an entry from the table.
      • clear

        public void clear()
        Clears the table.
      • rehash

        protected void rehash()
        Rehashes the table.