Input: key k
Output: the value for key k (if found) or null (not found)
start = hashValue(k);
i = start; // Start the search at "start"
do
{
Entry e;
e = bucket[i]; // 3 possibilities:
// (1) null, (2) special AVAILABLE, (3) valid entry
if ( e == null )
{
return null; // key k is not in hash table
}
else
{
if ( e == AVAILABLE )
{
i = (i + 1) % capacity; // Continue search
}
else if ( key.equals( e.key ) )
{
return e.value;
}
else
{
i = (i + 1) % capacity; // Continue search
}
}
} while ( i != start ); // Stop when search wrapped around
return null; // Not found after search wrapped around....
|