@VisibleForTesting public int find(long key) { long h = hash(key); int step = 0; int idx = (int) h & (numBuckets - 1); while (step < maxSteps) { // Return bucket index if it's either an empty slot or already contains the key if (buckets[idx] == -1) { return idx; } else if (equals(idx, key)) { return idx; } idx = (idx + 1) & (numBuckets - 1); step++; } // Didn't find it return -1; }
@VisibleForTesting public int find(long key) { long h = hash(key); int step = 0; int idx = (int) h & (numBuckets - 1); while (step < maxSteps) { // Return bucket index if it's either an empty slot or already contains the key if (buckets[idx] == -1) { return idx; } else if (equals(idx, key)) { return idx; } idx = (idx + 1) & (numBuckets - 1); step++; } // Didn't find it return -1; }
@VisibleForTesting public int find(long key) { long h = hash(key); int step = 0; int idx = (int) h & (numBuckets - 1); while (step < maxSteps) { // Return bucket index if it's either an empty slot or already contains the key if (buckets[idx] == -1) { return idx; } else if (equals(idx, key)) { return idx; } idx = (idx + 1) & (numBuckets - 1); step++; } // Didn't find it return -1; }
@VisibleForTesting public int find(long key) { long h = hash(key); int step = 0; int idx = (int) h & (numBuckets - 1); while (step < maxSteps) { // Return bucket index if it's either an empty slot or already contains the key if (buckets[idx] == -1) { return idx; } else if (equals(idx, key)) { return idx; } idx = (idx + 1) & (numBuckets - 1); step++; } // Didn't find it return -1; }