Code example for TreeSet

Methods: iteratorsize

0
    private int selectedColumn = -1; 
    private String currentSelectedMove;
    private Iterator<String> possibleSelectedMoves = null;
    protected final void handleClickOnCell(int xCell, int yCell, int xWithin, int yWithin) {
        if(selectedRow != yCell || selectedColumn != xCell || !possibleSelectedMoves.hasNext()) {
            SortedSet<String> theMoves = new TreeSet<String>(getLegalMovesForCell(xCell, yCell));
            if(theMoves.size() == 0)
                return; 
            possibleSelectedMoves = theMoves.iterator();            
        } 
         
        selectedRow = yCell;
        selectedColumn = xCell;
         
        currentSelectedMove = possibleSelectedMoves.next();        
        submitWorkingMove(stringToMove(currentSelectedMove));
    } 
 
    // Cache all of the facts about cells that we compute, since they should not 
    // change unless the game state changes.