Skip to content

Commit 323178d

Browse files
committed
Remove() Fix - True only if object is removed
1 parent 8428198 commit 323178d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/com/lewdev/probabilitylib/ProbabilityCollection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,14 @@ public boolean remove(E object) {
137137
}
138138

139139
Iterator<ProbabilitySetElement<E>> it = this.iterator();
140-
boolean removed = it.hasNext();
140+
boolean removed = false;
141141

142142
while(it.hasNext()) {
143143
ProbabilitySetElement<E> entry = it.next();
144144
if(entry.getObject().equals(object)) {
145145
this.totalProbability -= entry.getProbability();
146146
it.remove();
147+
removed = true;
147148
}
148149
}
149150

0 commit comments

Comments
 (0)