public class hdriver { public static void main(String[] args) { HashDictionary htable = new HashDictionary(new IntegerComparator()); int[][] board = { {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}, {1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,14}, {0,2,4,6,8,10,12,14,1,3,5,7,9,11,13,15}, {10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9}, {0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15}, {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}, {14,12,10,8,6,4,2,0,15,13,11,9,7,5,3,1}, {15,13,11,9,7,5,3,1,14,12,10,8,6,4,2,0}, {9,8,7,6,5,4,3,2,1,0,15,14,13,12,11,10}, {15,11,7,3,14,10,6,2,13,9,5,1,12,8,4,0}, {15,0,2,3,4,1,5,10,8,9,7,14,12,13,11,6} }; Board[] iBoard = new Board[11]; Position[] pos = new Position[11]; Position tmp; for(int i=0; i<11; i++) { iBoard[i] = new Board(board[i]); if(htable.find(iBoard[i]) != null) System.out.println("Board "+i+" is not inserted yet: -1"); pos[i]=htable.insert(new Integer(htable.formkey(iBoard[i])), htable.formelem(iBoard[i]) ); } for(int i=0; i<11; i++) if(htable.find(iBoard[i]) == null) System.out.println("Board "+i+" should be found: -1"); htable.remove(pos[4]); htable.remove(pos[8]); htable.remove(pos[1]); if(htable.find(iBoard[4]) != null) System.out.println("Board 4 should be removed"); if(htable.find(iBoard[8]) != null) System.out.println("Board 8 should be removed"); if(htable.find(iBoard[1]) != null) System.out.println("Board 1 should be removed"); if((tmp=htable.find(iBoard[6])) == null) System.out.println("Board 6 should be found"); else System.out.println( ((Item)tmp.element()).element() ); if((tmp=htable.find(iBoard[9])) == null) System.out.println("Board 9 should be found"); else System.out.println( ((Item)tmp.element()).element() ); if((tmp=htable.find(iBoard[0])) == null) System.out.println("Board 0 should be found"); else System.out.println( ((Item)tmp.element()).element() ); if((tmp=htable.find(iBoard[2])) == null) System.out.println("Board 2 should be found"); else System.out.println( ((Item)tmp.element()).element() ); if((tmp=htable.find(iBoard[9])) == null) System.out.println("Board 9 should be found"); else System.out.println( ((Item)tmp.element()).element() ); pos[8] = htable.insert(new Integer(htable.formkey(iBoard[8])), htable.formelem(iBoard[8]) ); if((tmp=htable.find(iBoard[8])) == null) System.out.println("Board 8 should be found"); else System.out.println( ((Item)tmp.element()).element() ); } }