mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-29 19:01:22 +01:00
Use an iterator for remove.
This commit is contained in:
parent
9efcf01766
commit
f70151d8c7
@ -1,6 +1,7 @@
|
|||||||
package fr.neatmonster.nocheatplus.utilities.ds.map;
|
package fr.neatmonster.nocheatplus.utilities.ds.map;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -143,14 +144,15 @@ public abstract class AbstractCoordHashMap<V, E extends fr.neatmonster.nocheatpl
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < bucket.size(); i++) {
|
final Iterator<E> it = bucket.iterator();
|
||||||
final E entry = bucket.get(i);
|
while (it.hasNext()) {
|
||||||
|
final E entry = it.next();
|
||||||
if (entry.hash == hash && x == entry.x && z == entry.z && y == entry.y) {
|
if (entry.hash == hash && x == entry.x && z == entry.z && y == entry.y) {
|
||||||
bucket.remove(entry);
|
it.remove();
|
||||||
|
size--;
|
||||||
if (bucket.isEmpty()) {
|
if (bucket.isEmpty()) {
|
||||||
entries[slot] = null;
|
entries[slot] = null;
|
||||||
}
|
}
|
||||||
size--;
|
|
||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ public class CoordHashMap<V> extends AbstractCoordHashMap<V, fr.neatmonster.noch
|
|||||||
* @param <V>
|
* @param <V>
|
||||||
*/
|
*/
|
||||||
public static class HashIterator<V> implements Iterator<Entry<V>> {
|
public static class HashIterator<V> implements Iterator<Entry<V>> {
|
||||||
|
|
||||||
|
// TODO: Switch to store an iterator?
|
||||||
|
|
||||||
private final CoordHashMap<V> map;
|
private final CoordHashMap<V> map;
|
||||||
private final List<HashEntry<V>>[] entries;
|
private final List<HashEntry<V>>[] entries;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user