Well, honestly I would just use Arrays.hashCode()
. You need your hashcode to be the same for any rotationally symetric array, so I would write a method which rotates your data 90 degrees, and one which reflects your data. At that point your code is something like:
public int hashCode() {
int[][] once = rotate(data);
int[][] twice = rotate(once);
int[][] thrice = rotate(twice);
int[][] flippedData = flip(data);
int[][] flippedOnce = flip(once);
int[][] flippedTwice = flip(twice);
int[][] flippedThrice = flip(thrice);
return Arrays.hashCode(data) + Arrays.hashCode(once) +
Arrays.hashCode(twice) + Arrays.hashCode(thrice) +
Arrays.hashCode(flippedData) + Arrays.hashCode(flippedOnce) +
Arrays.hashCode(flippedTwice) + Arrays.hashCode(flippedThrice);
}
That way, no matter the original orientation of your data, you still come up with the same ultimate hash code.