public Iterator<Operator<String>> validOperators(boolean reverse)
    {
        // Used to hold a list of valid moves
        List<Operator<String>> moves = new ArrayList<Operator<String>>(4);

        // Check if the up move is valid
        if (emptyY != 0)
        {
            moves.add(new OperatorImpl<String>("U"));
        }

        // Check if the down move is valid
        if (emptyY != 2)
        {
            moves.add(new OperatorImpl<String>("D"));
        }

        // Check if the left move is valid
        if (emptyX != 0)
        {
            moves.add(new OperatorImpl<String>("L"));
        }

        // Check if the right move is valid
        if (emptyX != 2)
        {
            moves.add(new OperatorImpl<String>("R"));
        }

        return moves.iterator();
    }
public Iterator < Operator < String > > validOperators ( boolean reverse ) { List < Operator < String > > moves = new ArrayList < Operator < String > > ( 4 ) ; if ( emptyY != 0 ) { moves . add ( new OperatorImpl < String > ( "U" ) ) ; } if ( emptyY != 2 ) { moves . add ( new OperatorImpl < String > ( "D" ) ) ; } if ( emptyX != 0 ) { moves . add ( new OperatorImpl < String > ( "L" ) ) ; } if ( emptyX != 2 ) { moves . add ( new OperatorImpl < String > ( "R" ) ) ; } return moves . iterator ( ) ; }
Supplies the valid moves for a board position.

@param  reverse Don't care about reverse orderings. Ignored.

@return An iterator over all the moves which are valid for this board position. This can be all 4, 3 or just 2
moves, depending if the empty tile is in the middle, edge or corner positions.