public class SingleSwapMove extends Object implements Move<PermutationSolution>
| Constructor and Description |
|---|
SingleSwapMove(int i,
int j)
Create a single swap move given the two positions in the permutation
at which items are to be swapped.
|
| Modifier and Type | Method and Description |
|---|---|
void |
apply(PermutationSolution solution)
Apply the move by swapping the items at the positions specified at construction.
|
boolean |
equals(Object obj)
Two single swap moves are considered equal if they swap the same pair of items.
|
int |
getI()
Get the position of the first swapped item.
|
int |
getJ()
Get the position of the second swapped item.
|
int |
hashCode()
Hash code computation corresponding to the implementation of
equals(Object). |
String |
toString()
Get string indicating move type and positions of swapped items.
|
void |
undo(PermutationSolution solution)
Undo a previously applied swap move.
|
public SingleSwapMove(int i,
int j)
i - position of first item to be swappedj - position of second item to be swappedpublic int getI()
public int getJ()
public void apply(PermutationSolution solution)
apply in interface Move<PermutationSolution>solution - permutation solution to which the move is appliedpublic void undo(PermutationSolution solution)
undo in interface Move<PermutationSolution>solution - permutation solution to which the move had been appliedpublic boolean equals(Object obj)
i and j is arbitrary.public int hashCode()
equals(Object).Copyright © 2016. All rights reserved.