Skip to content

Commit 5cf6682

Browse files
committed
review
1 parent d6b65ac commit 5cf6682

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

core/src/main/java/ai/timefold/solver/core/impl/move/MoveDirector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ private static <T> void moveInList(List<T> list, int from, int to) {
322322
Collections.swap(list, from, to);
323323
return;
324324
}
325-
var distanceTimesEight = (long) distance * 8L; // Prevents unlikely yet possible overflow.
325+
var distanceTimesEight = distance * 8L; // Long prevents unlikely yet possible overflow.
326326
var lowerIndex = Math.min(from, to);
327327
var tailLength = list.size() - lowerIndex;
328328
if (distanceTimesEight < tailLength) {

core/src/main/java/ai/timefold/solver/core/preview/api/move/MutableSolutionView.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ <Entity_, Value_> void unassignValue(PlanningListVariableMetaModel<Solution_, En
131131
* Acceptable values range from zero to one less than list size.
132132
* All values after the index are shifted to the left.
133133
* @return the removed value
134-
* @throws IndexOutOfBoundsException if the index is out of bounds
135134
*/
136135
<Entity_, Value_> Value_ unassignValue(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel,
137136
Entity_ entity, int index);
@@ -171,28 +170,29 @@ <Entity_, Value_> void changeVariable(PlanningVariableMetaModel<Solution_, Entit
171170
* All values at or after the index are shifted to the right.
172171
* To append to the end of the list, use the list size as index.
173172
* @return the value that was moved
174-
* @throws IndexOutOfBoundsException if either index is out of bounds
175173
* @throws IllegalArgumentException if sourceEntity == destinationEntity
176174
*/
177175
<Entity_, Value_> Value_ moveValueBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel,
178176
Entity_ sourceEntity, int sourceIndex, Entity_ destinationEntity, int destinationIndex);
179177

180178
/**
181-
* Replaces a value from one entity's {@link PlanningListVariable planning list variable} with another.
182-
* The value is removed from the replacementIndex, shifting all later values to the left.
183-
* The value is then added at the sourceIndex, replacing the pre-existing value and unassigning it.
184-
* This means that the replacement list will be one item shorter after the move.
179+
* Replaces a value in one entity's {@link PlanningListVariable planning list variable} with a value taken from another.
180+
* The value is removed from {@code replacementEntity} at {@code replacementIndex}, shifting all later values to the left.
181+
* The removed value is then assigned to {@code sourceEntity} at {@code sourceIndex},
182+
* overwriting the pre-existing value and unassigning it.
183+
* This means that the replacementEntity's list will be one item shorter after the move,
184+
* while the sourceEntity's list size remains unchanged.
185185
*
186186
* @param variableMetaModel Describes the variable to be changed.
187-
* @param sourceEntity The entity in which the value will be replaced.
188-
* @param sourceIndex The index in the source entity's list variable which contains the value to be replaced;
189-
* Acceptable values range from zero to one less than list size.
190-
* @param replacementEntity The entity from which the value will be taken.
191-
* @param replacementIndex The index in the replacementEntity's list variable which contains the value to be moved;
192-
* Acceptable values range from zero to one less than list size.
187+
* @param sourceEntity The entity in which the value at {@code sourceIndex} will be replaced (overwritten).
188+
* @param sourceIndex The index in the source entity's list variable whose current value will be overwritten;
189+
* Acceptable values range from zero to one less than the source list size.
190+
* @param replacementEntity The entity from which the replacement value will be taken and removed.
191+
* @param replacementIndex The index in the replacementEntity's list variable which contains the value to be moved and
192+
* removed;
193+
* Acceptable values range from zero to one less than the replacement list size.
193194
* All values at or after the index are shifted to the left.
194195
* @return the value that was replaced
195-
* @throws IndexOutOfBoundsException if either index is out of bounds
196196
* @throws IllegalArgumentException if sourceEntity == replacementEntity;
197197
* use {@link #replaceValueInList(PlanningListVariableMetaModel, Object, int, int)} instead.
198198
* @see #moveValueBetweenLists(PlanningListVariableMetaModel, Object, int, Object, int) Similar operation that moves the
@@ -275,7 +275,6 @@ <Entity_, Value_> Value_ replaceValueInList(PlanningListVariableMetaModel<Soluti
275275
* The offset must not be zero.
276276
* The offset must not move the value out of bounds.
277277
* @return the value that was moved
278-
* @throws IndexOutOfBoundsException if either index is out of bounds
279278
* @throws IllegalArgumentException if sourceIndex == destinationIndex
280279
* @see #moveValueInList(PlanningListVariableMetaModel, Object, int, int) Equivalent operation using index arithmetics
281280
* instead of offset calculation.
@@ -302,7 +301,6 @@ default <Entity_, Value_> Value_ shiftValue(PlanningListVariableMetaModel<Soluti
302301
* @param rightEntity The second entity whose variable value is to be swapped.
303302
* @param rightIndex The index in the right entity's list variable which contains the other value to be swapped;
304303
* Acceptable values range from zero to one less than list size.
305-
* @throws IndexOutOfBoundsException if either index is out of bounds
306304
* @throws IllegalArgumentException if leftEntity == rightEntity while leftIndex == rightIndex
307305
*/
308306
<Entity_, Value_> void swapValuesBetweenLists(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel,
@@ -317,7 +315,6 @@ <Entity_, Value_> void swapValuesBetweenLists(PlanningListVariableMetaModel<Solu
317315
* Acceptable values range from zero to one less than list size.
318316
* @param rightIndex The index in the entity's list variable which contains the other value to be swapped;
319317
* Acceptable values range from zero to one less than list size.
320-
* @throws IndexOutOfBoundsException if either index is out of bounds
321318
* @throws IllegalArgumentException if leftIndex == rightIndex
322319
*/
323320
<Entity_, Value_> void swapValuesInList(PlanningListVariableMetaModel<Solution_, Entity_, Value_> variableMetaModel,

0 commit comments

Comments
 (0)