import Supporting.*;
/**
* @author Mark Allen Weiss - Data Structures and Problem Solving Using Java - AW 1998
*/
final class Position implements Hashable
{
int [ ][ ] board;
int value;
Position( int theBoard[ ][ ] )
{
board = new int[ 3 ][ 3 ];
for( int i = 0; i < 3; i++ )
for( int j = 0; j < 3; j++ )
board[ i ][ j ] = theBoard[ i ][ j ];
}
public boolean equals( Object rhs )
{
for( int i = 0; i < 3; i++ )
for( int j = 0; j < 3; j++ )
if( board[ i ][ j ] != ( (Position) rhs ).board[ i ][ j ] )
return false;
return true;
}
public int hash( int tableSize )
{
int hashVal = 0;
for( int i = 0; i < 3; i++ )
for( int j = 0; j < 3; j++ )
hashVal = hashVal * 4 + board[ i ][ j ];
return hashVal % tableSize;
}
}