public void swap ( int i , int j ) { try { // swap items Collections . swap ( order , i , j ) ; } catch ( IndexOutOfBoundsException ex ) { throw new SolutionModificationException ( "Error while modifying permutation solution: swapped positions should be positive " + "and smaller than the number of items in the permutation." , this ) ; } }
Swap the items at position i and j in the permutation . Both positions should be positive and smaller than the number of items in the permutation .