public class SwapMove extends AbstractSubsetMove
Constructor and Description |
---|
SwapMove(int add,
int delete)
Creates a new swap move with specified IDs to add to and remove from the current selection
when being applied to a given subset solution.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(SubsetSolution solution)
Apply this swap move to a given subset solution.
|
int |
getAddedID()
Returns the added ID.
|
Set<Integer> |
getAddedIDs()
Returns an unmodifiable singleton containing the only added ID.
|
int |
getDeletedID()
Returns the deleted ID.
|
Set<Integer> |
getDeletedIDs()
Returns an unmodifiable singleton containing the only deleted ID.
|
int |
getNumAdded()
Always returns 1.
|
int |
getNumDeleted()
Always return 1.
|
void |
undo(SubsetSolution solution)
Undo this swap move after it has been successfully applied to the given subset solution,
by removing the newly added ID and re-adding the deleted ID.
|
equals, hashCode
public SwapMove(int add, int delete)
add
- ID to adddelete
- ID to deleteIllegalArgumentException
- if add == delete
public void apply(SubsetSolution solution)
undo(SubsetSolution)
will correctly
undo the move.solution
- solution to which to move will be appliedSolutionModificationException
- if the added ID is already selected, the deleted ID is already unselected,
or any of both IDs does not correspond to an underlying entitypublic void undo(SubsetSolution solution)
solution
- solution to which the move has been appliedpublic Set<Integer> getAddedIDs()
public int getAddedID()
public Set<Integer> getDeletedIDs()
public int getDeletedID()
public int getNumAdded()
public int getNumDeleted()
Copyright © 2016. All rights reserved.