Skip to content

Commit 3a84835

Browse files
fix: retract all nodes before updating the map
1 parent b1297a6 commit 3a84835

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/ai/timefold/solver/core/impl/bavet/uni/StaticDataUniNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public void insert(@Nullable Object a) {
6868
if (tupleMap.containsKey(a)) {
6969
return;
7070
}
71+
tupleMap.values().stream().flatMap(List::stream).forEach(this::retractExisting);
7172
tupleMap.put(a, new ArrayList<>());
7273
insertIntoNodeNetwork(a);
7374
recalculateTuples();
@@ -96,6 +97,7 @@ public void retract(@Nullable Object a) {
9697
if (!tupleMap.containsKey(a)) {
9798
return;
9899
}
100+
tupleMap.values().stream().flatMap(List::stream).forEach(this::retractExisting);
99101
tupleMap.remove(a);
100102
retractFromNodeNetwork(a);
101103
recalculateTuples();
@@ -135,8 +137,6 @@ private void retractFromNodeNetwork(Object toRetract) {
135137
}
136138

137139
private void recalculateTuples() {
138-
tupleMap.values().stream().flatMap(List::stream).forEach(this::retractExisting);
139-
140140
var recorder = recordingTupleNode.getTupleRecorder();
141141
recorder.reset();
142142
for (var mappedTupleEntry : tupleMap.entrySet()) {

0 commit comments

Comments
 (0)