Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColorCCCCFF
/* modulo function giving non-negative result */
private int imod(int i, int j)
{
  return (i < 0) ? ((-i) % j) : (i % j);
}
private int size=16;
	
public int[] hashTable=new int[size];
	
public int lookup(int hash)
{
  return hashTable[imod(ihash, jsize)];
}

Or, an explicit range check must be preformed on the numerator.

...