-
Notifications
You must be signed in to change notification settings - Fork 183
feat: add replaceValue... methods to MutableSolutionView #2180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7e69d2f
e69ab2c
938e393
d6b65ac
5cf6682
632aee4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,7 +131,6 @@ <Entity_, Value_> void unassignValue(PlanningListVariableMetaModel<Solution_, En | |
| * Acceptable values range from zero to one less than list size. | ||
| * All values after the index are shifted to the left. | ||
| * @return the removed value | ||
| * @throws IndexOutOfBoundsException if the index is out of bounds | ||
| */ | ||
| <Entity_, Value_> Value_ unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
| Entity_ entity, int index); | ||
|
|
@@ -171,12 +170,38 @@ <Entity_, Value_> void changeVariable(PlanningVariableMetaModel<Solution_, Entit | |
| * All values at or after the index are shifted to the right. | ||
| * To append to the end of the list, use the list size as index. | ||
| * @return the value that was moved | ||
| * @throws IndexOutOfBoundsException if either index is out of bounds | ||
| * @throws IllegalArgumentException if sourceEntity == destinationEntity | ||
| */ | ||
| <Entity_, Value_> Value_ moveValueBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
| Entity_ sourceEntity, int sourceIndex, Entity_ destinationEntity, int destinationIndex); | ||
|
|
||
| /** | ||
| * Replaces a value in one entity's {@link PlanningListVariable planning list variable} with a value taken from another. | ||
| * The value is removed from {@code replacementEntity} at {@code replacementIndex}, shifting all later values to the left. | ||
| * The removed value is then assigned to {@code sourceEntity} at {@code sourceIndex}, | ||
| * overwriting the pre-existing value and unassigning it. | ||
| * This means that the replacementEntity's list will be one item shorter after the move, | ||
| * while the sourceEntity's list size remains unchanged. | ||
| * | ||
| * @param variableMetaModel Describes the variable to be changed. | ||
| * @param sourceEntity The entity in which the value at {@code sourceIndex} will be replaced (overwritten). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: I would expect |
||
| * @param sourceIndex The index in the source entity's list variable whose current value will be overwritten; | ||
| * Acceptable values range from zero to one less than the source list size. | ||
| * @param replacementEntity The entity from which the replacement value will be taken and removed. | ||
| * @param replacementIndex The index in the replacementEntity's list variable which contains the value to be moved and | ||
| * removed; | ||
| * Acceptable values range from zero to one less than the replacement list size. | ||
| * All values at or after the index are shifted to the left. | ||
| * @return the value that was replaced | ||
| * @throws IllegalArgumentException if sourceEntity == replacementEntity; | ||
| * use {@link #replaceValueInList(PlanningListVariableMetaModel, Object, int, int)} instead. | ||
| * @see #moveValueBetweenLists(PlanningListVariableMetaModel, Object, int, Object, int) Similar operation that moves the | ||
| * value to the destination without removing the pre-existing value. | ||
| */ | ||
| <Entity_, Value_> Value_ replaceValueBetweenLists( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dislike the name |
||
| PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, Entity_ sourceEntity, int sourceIndex, | ||
| Entity_ replacementEntity, int replacementIndex); | ||
|
|
||
triceo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * As defined by {@link #moveValueBetweenLists(PlanningListVariableMetaModel, Object, int, Object, int)}, | ||
| * but using {@link PositionInList} to specify the source and destination positions. | ||
|
|
@@ -205,14 +230,39 @@ default <Entity_, Value_> Value_ moveValueBetweenLists( | |
| * Acceptable values range from zero to one less than list size. | ||
| * All values at or after the index are shifted to the right. | ||
| * @return the value that was moved | ||
| * @throws IndexOutOfBoundsException if either index is out of bounds | ||
| * @throws IllegalArgumentException if sourceIndex == destinationIndex | ||
| * @see #replaceValueInList(PlanningListVariableMetaModel, Object, int, int) Similar operation that replaces the value at | ||
| * the destination index instead. | ||
| * @see #shiftValue(PlanningListVariableMetaModel, Object, int, int) Equivalent operation using offset calculation instead | ||
| * of index arithmetics. | ||
| */ | ||
| <Entity_, Value_> Value_ moveValueInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
| Entity_ sourceEntity, int sourceIndex, int destinationIndex); | ||
|
|
||
| /** | ||
| * Moves a value within one entity's {@link PlanningListVariable planning list variable}. | ||
| * Behaves as if the value is first put in the replacementIndex, | ||
| * and then removed from the sourceIndex, shifting all later values to the left. | ||
| * The value previously at the replacementIndex is unassigned. | ||
| * | ||
| * @param variableMetaModel Describes the variable to be changed. | ||
| * @param sourceEntity The entity whose variable value is to be moved. | ||
| * @param sourceIndex The index in the source entity's list variable which contains the value to be moved; | ||
| * Acceptable values range from zero to one less than list size. | ||
| * All values after the index are shifted to the left. | ||
| * @param replacementIndex The index in the source entity's list variable to which the value will be moved; | ||
| * Acceptable values range from zero to one less than list size. | ||
| * The value previously at this index is unassigned. | ||
| * @return the value that was replaced | ||
| * @throws IllegalArgumentException if sourceIndex == replacementIndex | ||
| * @see #moveValueInList(PlanningListVariableMetaModel, Object, int, int) Similar operation that moves the value to the | ||
| * destination index instead. | ||
| * @see #shiftValue(PlanningListVariableMetaModel, Object, int, int) Equivalent operation using offset calculation instead | ||
| * of index arithmetic. | ||
| */ | ||
| <Entity_, Value_> Value_ replaceValueInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
| Entity_ sourceEntity, int sourceIndex, int replacementIndex); | ||
|
|
||
| /** | ||
| * Moves a value within one entity's {@link PlanningListVariable planning list variable}, | ||
| * by the given offset. | ||
|
|
@@ -225,7 +275,6 @@ <Entity_, Value_> Value_ moveValueInList(PlanningListVariableMetaModel<Solution_ | |
| * The offset must not be zero. | ||
| * The offset must not move the value out of bounds. | ||
| * @return the value that was moved | ||
| * @throws IndexOutOfBoundsException if either index is out of bounds | ||
| * @throws IllegalArgumentException if sourceIndex == destinationIndex | ||
| * @see #moveValueInList(PlanningListVariableMetaModel, Object, int, int) Equivalent operation using index arithmetics | ||
| * instead of offset calculation. | ||
|
|
@@ -252,7 +301,6 @@ default <Entity_, Value_> Value_ shiftValue(PlanningListVariableMetaModel<Soluti | |
| * @param rightEntity The second entity whose variable value is to be swapped. | ||
| * @param rightIndex The index in the right entity's list variable which contains the other value to be swapped; | ||
| * Acceptable values range from zero to one less than list size. | ||
| * @throws IndexOutOfBoundsException if either index is out of bounds | ||
| * @throws IllegalArgumentException if leftEntity == rightEntity while leftIndex == rightIndex | ||
| */ | ||
| <Entity_, Value_> void swapValuesBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
|
|
@@ -267,7 +315,6 @@ <Entity_, Value_> void swapValuesBetweenLists(PlanningListVariableMetaModel<Solu | |
| * Acceptable values range from zero to one less than list size. | ||
| * @param rightIndex The index in the entity's list variable which contains the other value to be swapped; | ||
| * Acceptable values range from zero to one less than list size. | ||
| * @throws IndexOutOfBoundsException if either index is out of bounds | ||
| * @throws IllegalArgumentException if leftIndex == rightIndex | ||
| */ | ||
| <Entity_, Value_> void swapValuesInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.