mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Regid fixes
This commit is contained in:
parent
babefc7bd3
commit
62f6917d81
@ -22,6 +22,7 @@ import com.google.common.base.Predicates;
|
|||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -29,54 +30,42 @@ import java.util.List;
|
|||||||
public class RegistryBlockID<T> implements Registry<T> {
|
public class RegistryBlockID<T> implements Registry<T> {
|
||||||
public static final int a = -1;
|
public static final int a = -1;
|
||||||
private int b;
|
private int b;
|
||||||
private final IdentityHashMap<T, Integer> c;
|
private final HashMap<T, Integer> indexMap;
|
||||||
private final List<T> d;
|
private final List<T> indexes;
|
||||||
|
|
||||||
|
public RegistryBlockID(IdentityHashMap<T, Integer> c, List<T> d, int b) {
|
||||||
|
this.indexMap = new HashMap<>(c);
|
||||||
|
this.indexes = d;
|
||||||
|
this.b = b;
|
||||||
|
}
|
||||||
|
|
||||||
public RegistryBlockID() {
|
public RegistryBlockID() {
|
||||||
this(512);
|
this(512);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegistryBlockID(int var0) {
|
public RegistryBlockID(int var0) {
|
||||||
this.d = Lists.newArrayListWithExpectedSize(var0);
|
this.indexes = Lists.newArrayListWithExpectedSize(var0);
|
||||||
this.c = new IdentityHashMap(var0);
|
this.indexMap = new HashMap<>(var0);
|
||||||
}
|
|
||||||
|
|
||||||
public void a(T var0, int var1) {
|
|
||||||
this.c.put(var0, var1);
|
|
||||||
|
|
||||||
while (this.d.size() <= var1) {
|
|
||||||
this.d.add(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.d.set(var1, var0);
|
|
||||||
if (this.b <= var1) {
|
|
||||||
this.b = var1 + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void b(T var0) {
|
|
||||||
this.a(var0, this.b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId(T var0) {
|
public int getId(T var0) {
|
||||||
Integer var1 = (Integer) this.c.get(var0);
|
Integer var1 = this.indexMap.get(var0);
|
||||||
return var1 == null ? -1 : var1;
|
return var1 == null ? -1 : var1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final T fromId(int var0) {
|
public final T fromId(int var0) {
|
||||||
return var0 >= 0 && var0 < this.d.size() ? this.d.get(var0) : null;
|
return var0 >= 0 && var0 < this.indexes.size() ? this.indexes.get(var0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<T> iterator() {
|
public Iterator<T> iterator() {
|
||||||
return Iterators.filter(this.d.iterator(), Predicates.notNull());
|
return Iterators.filter(this.indexes.iterator(), Predicates.notNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean b(int var0) {
|
public boolean hasIndex(int var0) {
|
||||||
return this.fromId(var0) != null;
|
return this.fromId(var0) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int a() {
|
public int size() {
|
||||||
return this.c.size();
|
return this.indexMap.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user