Advertisement
Guest User

Untitled

a guest
Apr 1st, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. Class SodokuBoard {
  2.     static class BoardCellIndex {
  3.         public int row;
  4.         public int col;
  5.         public BoardCellIndex(int row, int col){
  6.             this.row = row;
  7.             this.col = col;
  8.         }
  9.     }
  10.  
  11.     Map<BoardCellIndex, List<Integer>> board;
  12.  
  13.     public SodokuBoard(){
  14.         board = new HashMap<BoardCellIndex, List<Integer>>();
  15.         tmpIndex = new BoardCellIndex(0,0);
  16.        
  17.         // init board
  18.         for(int row = 0; row < 9 ; ++row){
  19.             for( int col = 0; col < 9 ; ++col){
  20.                 BoardCellIndex index = new BoardCellIndex(row, col);
  21.                 board.put(index, new ArrayList<Integer>);
  22.             }
  23.         }
  24.     }
  25.  
  26.     // don't create new object for access of Map
  27.     BoardCellIndex tmpIndex;
  28.  
  29.     /**
  30.     * Ezen keresztul elered az adott cellahoz tartozo List<int>-et
  31.     * ami a jelölteket tartalmazza, es hozza tudsz adni vagy el tudsz venni
  32.     * jelolteket
  33.     * pl.
  34.     * myboard.getCandidates(1,2).add(9);
  35.     * myboard.getCandidates(1.3).remove(1);
  36.     */
  37.     public List<int> getCandidates(int row, int col){
  38.         tmpIndex.row = row;
  39.         tmpIndex.col = col;
  40.         return board.get(tmpIndex);
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement