public class Hopscotch
{
private int maxDist;
private int maxSize;
private Cell [] table;
public Hopscotch(int dist, int size)
{
// Attempt to put the data into the table at index hashValue.
// If that space is taken, then we do linear probing, but only
// within the limitation of the MAX_DIST.
// Also make the approprate change to the “hop” entry in the cell.
// If linear probing goes too far, then we must follow the eviction\
// procedure explained in the text.
// First, see if this cell is occupied or available.
boolean available = table[hashValue].data == null;
{
//System.out.printf(“Need to try some linear probing.\n”);
boolean successfullyPlaced = false;
for (int i = 1; i < maxDist; ++i)
{
// Reject a table index that is too high!
if (hashValue + i >= maxSize)