public void find(int key) // find item with key
{
int numberProbes = 0;
int hashVal = hashFunc(key); // hash the key
while(hashArray[hashVal] != null) // until empty cell,
{ // found the key?
numberProbes++;
if(hashArray[hashVal].getKey() == key)
{
numberProbesSuccess += numberProbes; // update # of probes for success
totalSuccess++;
// System.out.println("Number of probes: " + numberProbes);
return; // yes, return item
}
else
{
hashVal++; // go to next cell
hashVal %= arraySize; // wraparound if necessary
}
} // end while
numberProbes++;
// System.out.println("Number of probes: " + numberProbes);
numberProbesFail += numberProbes; // update # of probes for failure
return; // can't find item
}