Source of 22.13.java


  1: // Precondition: checkInitialization has been called.
  2: private int locate(int index, K key)
  3: {
  4:    boolean found = false;
  5: 
  6:    while ( !found && (hashTable[index] != null) )
  7:    {
  8:       if ( hashTable[index].isIn() && key.equals(hashTable[index].getKey()) )
  9:          found = true; // Key found
 10:       else             // Follow probe sequence
 11:          index = (index + 1) % hashTable.length;         // Linear probing
 12:    } // end while
 13:    // Assertion: Either key or null is found at hashTable[index]
 14: 
 15:    int result = -1;
 16:    if (found)
 17:       result = index;
 18: 
 19:    return result;
 20: } // end locate
 21: // Version 4.0