Code example for TreeSet

Methods: iterator, size

0
    private int selectedRectangle = -1;
    private String currentSelectedMove;
    private Iterator<String> possibleSelectedMoves = null;
    protected final void handleClickOnRectangle(int nRectangle) {
        if(selectedRectangle != nRectangle || !possibleSelectedMoves.hasNext()) {
            SortedSet<String> theMoves = new TreeSet<String>(getLegalMovesForRectangle(nRectangle));
            if(theMoves.size() == 0)
                return; 
            possibleSelectedMoves = theMoves.iterator();            
        } 
         
        selectedRectangle = nRectangle;
         
        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. 
    private Map<Integer, Set<String>> factsCache = new HashMap<Integer, Set<String>>();
    protected Set<String> getCachedFactsAboutRectangle(int nRectangle) {