Hashing with Buckets: Code

The basic code for hashing with buckets is very simple:


public void insert( String key ) {
   int hashindex = hashfix(key.hashCode(),
                           hashtable.length);
   hashtable[hashindex] =
        cons(key, hashtable[hashindex]); }

public boolean contains( String key ) {
   int hashindex = hashfix(key.hashCode(),
                           hashtable.length);
   Cons item =
     member(key, hashtable[hashindex]);
   return ( item != null ); }

Contents    Page-10    Prev    Next    Page+10    Index