We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7903ff1 commit 5d86d26Copy full SHA for 5d86d26
1 file changed
src/main/java/by/andd3dfx/collections/RandomizedSet.java
@@ -68,8 +68,11 @@ public boolean remove(int val) {
68
var isExist = map.containsKey(val);
69
if (isExist) {
70
var index = map.get(val);
71
- values.set(index, values.getLast());
72
- map.put(values.get(index), index);
+
+ var lastValue = values.getLast();
73
+ values.set(index, lastValue);
74
+ map.put(lastValue, index);
75
76
values.removeLast();
77
map.remove(val);
78
}
0 commit comments