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