Hashtable
    Rubén del Río del Blanco
                  uo168319
Java Hashtable


   Relates a key with a value.
   Any non-null object can be used as a key or as
    a value.
   Should be implemented hashcode and equals
    methods for the objects used as keys.
   Objects in the hash table have two parameters
    initial capacity and load factor.
Using Object Types




   Store pairs of type, object type key value.
Hash function

   Returns a value that represents the position in
    the table
   Using Horner's rule.

      private int hash(String key){
          int p=0;
          for(int i=0;i<key.length() && i<3;i++){
          p=(p*32+key.charAt(i))%table.length;
          }
      return p;
      }

Hashtable

  • 1.
    Hashtable Rubén del Río del Blanco uo168319
  • 2.
    Java Hashtable  Relates a key with a value.  Any non-null object can be used as a key or as a value.  Should be implemented hashcode and equals methods for the objects used as keys.  Objects in the hash table have two parameters initial capacity and load factor.
  • 3.
    Using Object Types  Store pairs of type, object type key value.
  • 4.
    Hash function  Returns a value that represents the position in the table  Using Horner's rule. private int hash(String key){ int p=0; for(int i=0;i<key.length() && i<3;i++){ p=(p*32+key.charAt(i))%table.length; } return p; }