package it.unimi.dsi.fastutil.objects;
import it.unimi.dsi.fastutil.Hash;
import it.unimi.dsi.fastutil.HashCommon;
import static it.unimi.dsi.fastutil.HashCommon.arraySize;
import static it.unimi.dsi.fastutil.HashCommon.maxFill;
import java.util.Map;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.function.Consumer;
import it.unimi.dsi.fastutil.bytes.ByteCollection;
import it.unimi.dsi.fastutil.bytes.AbstractByteCollection;
import it.unimi.dsi.fastutil.bytes.ByteIterator;
import it.unimi.dsi.fastutil.objects.AbstractObjectSet;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
public class Object2ByteOpenHashMap<K> extends AbstractObject2ByteMap<K>
implements
java.io.Serializable,
Cloneable,
Hash {
private static final long serialVersionUID = 0L;
private static final boolean ASSERTS = false;
protected transient K[] key;
protected transient byte[] value;
protected transient int mask;
protected transient boolean containsNullKey;
protected transient int n;
protected transient int maxFill;
protected final transient int minN;
protected int size;
protected final float f;
protected transient FastEntrySet<K> entries;
protected transient ObjectSet<K> keys;
protected transient ByteCollection values;
@SuppressWarnings("unchecked")
public Object2ByteOpenHashMap(final int expected, final float f) {
if (f <= 0 || f > 1)
throw new IllegalArgumentException("Load factor must be greater than 0 and smaller than or equal to 1");
if (expected < 0)
throw new IllegalArgumentException("The expected number of elements must be nonnegative");
this.f = f;
minN = n = arraySize(expected, f);
mask = n - 1;
maxFill = maxFill(n, f);
key = (K[]) new Object[n + 1];
value = new byte[n + 1];
}
public Object2ByteOpenHashMap(final int expected) {
this(expected, DEFAULT_LOAD_FACTOR);
}
public Object2ByteOpenHashMap() {
this(DEFAULT_INITIAL_SIZE, DEFAULT_LOAD_FACTOR);
}
public Object2ByteOpenHashMap(final Map<? extends K, ? extends Byte> m, final float f) {
this(m.size(), f);
putAll(m);
}
public Object2ByteOpenHashMap(final Map<? extends K, ? extends Byte> m) {
this(m, DEFAULT_LOAD_FACTOR);
}
public Object2ByteOpenHashMap(final Object2ByteMap<K> m, final float f) {
this(m.size(), f);
putAll(m);
}
public Object2ByteOpenHashMap(final Object2ByteMap<K> m) {
this(m, DEFAULT_LOAD_FACTOR);
}
public Object2ByteOpenHashMap(final K[] k, final byte[] v, final float f) {
this(k.length, f);
if (k.length != v.length)
throw new IllegalArgumentException(
"The key array and the value array have different lengths (" + k.length + " and " + v.length + ")");
for (int i = 0; i < k.length; i++)
this.put(k[i], v[i]);
}
public Object2ByteOpenHashMap(final K[] k, final byte[] v) {
this(k, v, DEFAULT_LOAD_FACTOR);
}
private int realSize() {
return containsNullKey ? size - 1 : size;
}
private void ensureCapacity(final int capacity) {
final int needed = arraySize(capacity, f);
if (needed > n)
rehash(needed);
}
private void tryCapacity(final long capacity) {
final int needed = (int) Math.min(1 << 30,
Math.max(2, HashCommon.nextPowerOfTwo((long) Math.ceil(capacity / f))));
if (needed > n)
rehash(needed);
}
private byte removeEntry(final int pos) {
final byte oldValue = value[pos];
size--;
shiftKeys(pos);
if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE)
rehash(n / 2);
return oldValue;
}
private byte removeNullEntry() {
containsNullKey = false;
key[n] = null;
final byte oldValue = value[n];
size--;
if (n > minN && size < maxFill / 4 && n > DEFAULT_INITIAL_SIZE)
rehash(n / 2);
return oldValue;
}
@Override
public void putAll(Map<? extends K, ? extends Byte> m) {
if (f <= .5)
ensureCapacity(m.size());
else
tryCapacity(size() + m.size());
super.putAll(m);
}
@SuppressWarnings("unchecked")
private int find(final K k) {
if (((k) == null))
return containsNullKey ? n : -(n + 1);
K curr;
final K[] key = this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return -(pos + 1);
if (((k).equals(curr)))
return pos;
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return -(pos + 1);
if (((k).equals(curr)))
return pos;
}
}
private void insert(final int pos, final K k, final byte v) {
if (pos == n)
containsNullKey = true;
key[pos] = k;
value[pos] = v;
if (size++ >= maxFill)
rehash(arraySize(size + 1, f));
if (ASSERTS)
checkTable();
}
@Override
public byte put(final K k, final byte v) {
final int pos = find(k);
if (pos < 0) {
insert(-pos - 1, k, v);
return defRetValue;
}
final byte oldValue = value[pos];
value[pos] = v;
return oldValue;
}
private byte addToValue(final int pos, final byte incr) {
final byte oldValue = value[pos];
value[pos] = (byte) (oldValue + incr);
return oldValue;
}
public byte addTo(final K k, final byte incr) {
int pos;
if (((k) == null)) {
if (containsNullKey)
return addToValue(n, incr);
pos = n;
containsNullKey = true;
} else {
K curr;
final K[] key = this.key;
if (!((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null)) {
if (((curr).equals(k)))
return addToValue(pos, incr);
while (!((curr = key[pos = (pos + 1) & mask]) == null))
if (((curr).equals(k)))
return addToValue(pos, incr);
}
}
key[pos] = k;
value[pos] = (byte) (defRetValue + incr);
if (size++ >= maxFill)
rehash(arraySize(size + 1, f));
if (ASSERTS)
checkTable();
return defRetValue;
}
protected final void shiftKeys(int pos) {
int last, slot;
K curr;
final K[] key = this.key;
for (;;) {
pos = ((last = pos) + 1) & mask;
for (;;) {
if (((curr = key[pos]) == null)) {
key[last] = (null);
return;
}
slot = (it.unimi.dsi.fastutil.HashCommon.mix((curr).hashCode())) & mask;
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos)
break;
pos = (pos + 1) & mask;
}
key[last] = curr;
value[last] = value[pos];
}
}
@Override
@SuppressWarnings("unchecked")
public byte removeByte(final Object k) {
if ((((K) k) == null)) {
if (containsNullKey)
return removeNullEntry();
return defRetValue;
}
K curr;
final K[] key = this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return defRetValue;
if (((k).equals(curr)))
return removeEntry(pos);
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return defRetValue;
if (((k).equals(curr)))
return removeEntry(pos);
}
}
@Override
@SuppressWarnings("unchecked")
public byte getByte(final Object k) {
if ((((K) k) == null))
return containsNullKey ? value[n] : defRetValue;
K curr;
final K[] key = this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return defRetValue;
if (((k).equals(curr)))
return value[pos];
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return defRetValue;
if (((k).equals(curr)))
return value[pos];
}
}
@Override
@SuppressWarnings("unchecked")
public boolean containsKey(final Object k) {
if ((((K) k) == null))
return containsNullKey;
K curr;
final K[] key = this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return false;
if (((k).equals(curr)))
return true;
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return false;
if (((k).equals(curr)))
return true;
}
}
@Override
public boolean containsValue(final byte v) {
final byte value[] = this.value;
final K key[] = this.key;
if (containsNullKey && ((value[n]) == (v)))
return true;
for (int i = n; i-- != 0;)
if (!((key[i]) == null) && ((value[i]) == (v)))
return true;
return false;
}
@Override
@SuppressWarnings("unchecked")
public byte getOrDefault(final Object k, final byte defaultValue) {
if ((((K) k) == null))
return containsNullKey ? value[n] : defaultValue;
K curr;
final K[] key = this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return defaultValue;
if (((k).equals(curr)))
return value[pos];
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return defaultValue;
if (((k).equals(curr)))
return value[pos];
}
}
@Override
public byte putIfAbsent(final K k, final byte v) {
final int pos = find(k);
if (pos >= 0)
return value[pos];
insert(-pos - 1, k, v);
return defRetValue;
}
@Override
@SuppressWarnings("unchecked")
public boolean remove(final Object k, final byte v) {
if ((((K) k) == null)) {
if (containsNullKey && ((v) == (value[n]))) {
removeNullEntry();
return true;
}
return false;
}
K curr;
final K[] key = this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return false;
if (((k).equals(curr)) && ((v) == (value[pos]))) {
removeEntry(pos);
return true;
}
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return false;
if (((k).equals(curr)) && ((v) == (value[pos]))) {
removeEntry(pos);
return true;
}
}
}
@Override
public boolean replace(final K k, final byte oldValue, final byte v) {
final int pos = find(k);
if (pos < 0 || !((oldValue) == (value[pos])))
return false;
value[pos] = v;
return true;
}
@Override
public byte replace(final K k, final byte v) {
final int pos = find(k);
if (pos < 0)
return defRetValue;
final byte oldValue = value[pos];
value[pos] = v;
return oldValue;
}
@Override
public byte computeByteIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) {
java.util.Objects.requireNonNull(mappingFunction);
final int pos = find(k);
if (pos >= 0)
return value[pos];
final byte newValue = it.unimi.dsi.fastutil.SafeMath.safeIntToByte(mappingFunction.applyAsInt(k));
insert(-pos - 1, k, newValue);
return newValue;
}
@Override
public byte computeByteIfPresent(final K k,
final java.util.function.BiFunction<? super K, ? super Byte, ? extends Byte> remappingFunction) {
java.util.Objects.requireNonNull(remappingFunction);
final int pos = find(k);
if (pos < 0)
return defRetValue;
final Byte newValue = remappingFunction.apply((k), Byte.valueOf(value[pos]));
if (newValue == null) {
if (((k) == null))
removeNullEntry();
else
removeEntry(pos);
return defRetValue;
}
return value[pos] = (newValue).byteValue();
}
@Override
public byte computeByte(final K k,
final java.util.function.BiFunction<? super K, ? super Byte, ? extends Byte> remappingFunction) {
java.util.Objects.requireNonNull(remappingFunction);
final int pos = find(k);
final Byte newValue = remappingFunction.apply((k), pos >= 0 ? Byte.valueOf(value[pos]) : null);
if (newValue == null) {
if (pos >= 0) {
if (((k) == null))
removeNullEntry();
else
removeEntry(pos);
}
return defRetValue;
}
byte newVal = (newValue).byteValue();
if (pos < 0) {
insert(-pos - 1, k, newVal);
return newVal;
}
return value[pos] = newVal;
}
@Override
public byte mergeByte(final K k, final byte v,
final java.util.function.BiFunction<? super Byte, ? super Byte, ? extends Byte> remappingFunction) {
java.util.Objects.requireNonNull(remappingFunction);
final int pos = find(k);
if (pos < 0) {
insert(-pos - 1, k, v);
return v;
}
final Byte newValue = remappingFunction.apply(Byte.valueOf(value[pos]), Byte.valueOf(v));
if (newValue == null) {
if (((k) == null))
removeNullEntry();
else
removeEntry(pos);
return defRetValue;
}
return value[pos] = (newValue).byteValue();
}
@Override
public void clear() {
if (size == 0)
return;
size = 0;
containsNullKey = false;
Arrays.fill(key, (null));
}
@Override
public int size() {
return size;
}
@Override
public boolean isEmpty() {
return size == 0;
}
final class MapEntry implements Object2ByteMap.Entry<K>, Map.Entry<K, Byte> {
int index;
MapEntry(final int index) {
this.index = index;
}
MapEntry() {
}
@Override
public K getKey() {
return key[index];
}
@Override
public byte getByteValue() {
return value[index];
}
@Override
public byte setValue(final byte v) {
final byte oldValue = value[index];
value[index] = v;
return oldValue;
}
@Deprecated
@Override
public Byte getValue() {
return Byte.valueOf(value[index]);
}
@Deprecated
@Override
public Byte setValue(final Byte v) {
return Byte.valueOf(setValue((v).byteValue()));
}
@SuppressWarnings("unchecked")
@Override
public boolean equals(final Object o) {
if (!(o instanceof Map.Entry))
return false;
Map.Entry<K, Byte> e = (Map.Entry<K, Byte>) o;
return java.util.Objects.equals(key[index], (e.getKey()))
&& ((value[index]) == ((e.getValue()).byteValue()));
}
@Override
public int hashCode() {
return ((key[index]) == null ? 0 : (key[index]).hashCode()) ^ (value[index]);
}
@Override
public String toString() {
return key[index] + "=>" + value[index];
}
}
private class MapIterator {
int pos = n;
int last = -1;
int c = size;
boolean mustReturnNullKey = Object2ByteOpenHashMap.this.containsNullKey;
ObjectArrayList<K> wrapped;
public boolean hasNext() {
return c != 0;
}
public int nextEntry() {
if (!hasNext())
throw new NoSuchElementException();
c--;
if (mustReturnNullKey) {
mustReturnNullKey = false;
return last = n;
}
final K key[] = Object2ByteOpenHashMap.this.key;
for (;;) {
if (--pos < 0) {
last = Integer.MIN_VALUE;
final K k = wrapped.get(-pos - 1);
int p = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask;
while (!((k).equals(key[p])))
p = (p + 1) & mask;
return p;
}
if (!((key[pos]) == null))
return last = pos;
}
}
private void shiftKeys(int pos) {
int last, slot;
K curr;
final K[] key = Object2ByteOpenHashMap.this.key;
for (;;) {
pos = ((last = pos) + 1) & mask;
for (;;) {
if (((curr = key[pos]) == null)) {
key[last] = (null);
return;
}
slot = (it.unimi.dsi.fastutil.HashCommon.mix((curr).hashCode())) & mask;
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos)
break;
pos = (pos + 1) & mask;
}
if (pos < last) {
if (wrapped == null)
wrapped = new ObjectArrayList<>(2);
wrapped.add(key[pos]);
}
key[last] = curr;
value[last] = value[pos];
}
}
public void remove() {
if (last == -1)
throw new IllegalStateException();
if (last == n) {
containsNullKey = false;
key[n] = null;
} else if (pos >= 0)
shiftKeys(last);
else {
Object2ByteOpenHashMap.this.removeByte(wrapped.set(-pos - 1, null));
last = -1;
return;
}
size--;
last = -1;
if (ASSERTS)
checkTable();
}
public int skip(final int n) {
int i = n;
while (i-- != 0 && hasNext())
nextEntry();
return n - i - 1;
}
}
private class EntryIterator extends MapIterator implements ObjectIterator<Object2ByteMap.Entry<K>> {
private MapEntry entry;
@Override
public MapEntry next() {
return entry = new MapEntry(nextEntry());
}
@Override
public void remove() {
super.remove();
entry.index = -1;
}
}
private class FastEntryIterator extends MapIterator implements ObjectIterator<Object2ByteMap.Entry<K>> {
private final MapEntry entry = new MapEntry();
@Override
public MapEntry next() {
entry.index = nextEntry();
return entry;
}
}
private final class MapEntrySet extends AbstractObjectSet<Object2ByteMap.Entry<K>> implements FastEntrySet<K> {
@Override
public ObjectIterator<Object2ByteMap.Entry<K>> iterator() {
return new EntryIterator();
}
@Override
public ObjectIterator<Object2ByteMap.Entry<K>> fastIterator() {
return new FastEntryIterator();
}
@Override
@SuppressWarnings("unchecked")
public boolean contains(final Object o) {
if (!(o instanceof Map.Entry))
return false;
final Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
if (e.getValue() == null || !(e.getValue() instanceof Byte))
return false;
final K k = ((K) e.getKey());
final byte v = ((Byte) (e.getValue())).byteValue();
if (((k) == null))
return Object2ByteOpenHashMap.this.containsNullKey && ((value[n]) == (v));
K curr;
final K[] key = Object2ByteOpenHashMap.this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return false;
if (((k).equals(curr)))
return ((value[pos]) == (v));
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return false;
if (((k).equals(curr)))
return ((value[pos]) == (v));
}
}
@Override
@SuppressWarnings("unchecked")
public boolean remove(final Object o) {
if (!(o instanceof Map.Entry))
return false;
final Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
if (e.getValue() == null || !(e.getValue() instanceof Byte))
return false;
final K k = ((K) e.getKey());
final byte v = ((Byte) (e.getValue())).byteValue();
if (((k) == null)) {
if (containsNullKey && ((value[n]) == (v))) {
removeNullEntry();
return true;
}
return false;
}
K curr;
final K[] key = Object2ByteOpenHashMap.this.key;
int pos;
if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask]) == null))
return false;
if (((curr).equals(k))) {
if (((value[pos]) == (v))) {
removeEntry(pos);
return true;
}
return false;
}
while (true) {
if (((curr = key[pos = (pos + 1) & mask]) == null))
return false;
if (((curr).equals(k))) {
if (((value[pos]) == (v))) {
removeEntry(pos);
return true;
}
}
}
}
@Override
public int size() {
return size;
}
@Override
public void clear() {
Object2ByteOpenHashMap.this.clear();
}
@Override
public void forEach(final Consumer<? super Object2ByteMap.Entry<K>> consumer) {
if (containsNullKey)
consumer.accept(new AbstractObject2ByteMap.BasicEntry<K>(key[n], value[n]));
for (int pos = n; pos-- != 0;)
if (!((key[pos]) == null))
consumer.accept(new AbstractObject2ByteMap.BasicEntry<K>(key[pos], value[pos]));
}
@Override
public void fastForEach(final Consumer<? super Object2ByteMap.Entry<K>> consumer) {
final AbstractObject2ByteMap.BasicEntry<K> entry = new AbstractObject2ByteMap.BasicEntry<>();
if (containsNullKey) {
entry.key = key[n];
entry.value = value[n];
consumer.accept(entry);
}
for (int pos = n; pos-- != 0;)
if (!((key[pos]) == null)) {
entry.key = key[pos];
entry.value = value[pos];
consumer.accept(entry);
}
}
}
@Override
public FastEntrySet<K> object2ByteEntrySet() {
if (entries == null)
entries = new MapEntrySet();
return entries;
}
private final class KeyIterator extends MapIterator implements ObjectIterator<K> {
public KeyIterator() {
super();
}
@Override
public K next() {
return key[nextEntry()];
}
}
private final class KeySet extends AbstractObjectSet<K> {
@Override
public ObjectIterator<K> iterator() {
return new KeyIterator();
}
@Override
public void forEach(final Consumer<? super K> consumer) {
if (containsNullKey)
consumer.accept(key[n]);
for (int pos = n; pos-- != 0;) {
final K k = key[pos];
if (!((k) == null))
consumer.accept(k);
}
}
@Override
public int size() {
return size;
}
@Override
public boolean contains(Object k) {
return containsKey(k);
}
@Override
public boolean remove(Object k) {
final int oldSize = size;
Object2ByteOpenHashMap.this.removeByte(k);
return size != oldSize;
}
@Override
public void clear() {
Object2ByteOpenHashMap.this.clear();
}
}
@Override
public ObjectSet<K> keySet() {
if (keys == null)
keys = new KeySet();
return keys;
}
private final class ValueIterator extends MapIterator implements ByteIterator {
public ValueIterator() {
super();
}
@Override
public byte nextByte() {
return value[nextEntry()];
}
}
@Override
public ByteCollection values() {
if (values == null)
values = new AbstractByteCollection() {
@Override
public ByteIterator iterator() {
return new ValueIterator();
}
@Override
public int size() {
return size;
}
@Override
public boolean contains(byte v) {
return containsValue(v);
}
@Override
public void clear() {
Object2ByteOpenHashMap.this.clear();
}
@Override
public void forEach(final java.util.function.IntConsumer consumer) {
if (containsNullKey)
consumer.accept(value[n]);
for (int pos = n; pos-- != 0;)
if (!((key[pos]) == null))
consumer.accept(value[pos]);
}
};
return values;
}
public boolean trim() {
return trim(size);
}
public boolean trim(final int n) {
final int l = HashCommon.nextPowerOfTwo((int) Math.ceil(n / f));
if (l >= this.n || size > maxFill(l, f))
return true;
try {
rehash(l);
} catch (OutOfMemoryError cantDoIt) {
return false;
}
return true;
}
@SuppressWarnings("unchecked")
protected void rehash(final int newN) {
final K key[] = this.key;
final byte value[] = this.value;
final int mask = newN - 1;
final K newKey[] = (K[]) new Object[newN + 1];
final byte newValue[] = new byte[newN + 1];
int i = n, pos;
for (int j = realSize(); j-- != 0;) {
while (((key[--i]) == null));
if (!((newKey[pos = (it.unimi.dsi.fastutil.HashCommon.mix((key[i]).hashCode())) & mask]) == null))
while (!((newKey[pos = (pos + 1) & mask]) == null));
newKey[pos] = key[i];
newValue[pos] = value[i];
}
newValue[newN] = value[n];
n = newN;
this.mask = mask;
maxFill = maxFill(n, f);
this.key = newKey;
this.value = newValue;
}
@Override
@SuppressWarnings("unchecked")
public Object2ByteOpenHashMap<K> clone() {
Object2ByteOpenHashMap<K> c;
try {
c = (Object2ByteOpenHashMap<K>) super.clone();
} catch (CloneNotSupportedException cantHappen) {
throw new InternalError();
}
c.keys = null;
c.values = null;
c.entries = null;
c.containsNullKey = containsNullKey;
c.key = key.clone();
c.value = value.clone();
return c;
}
@Override
public int hashCode() {
int h = 0;
for (int j = realSize(), i = 0, t = 0; j-- != 0;) {
while (((key[i]) == null))
i++;
if (this != key[i])
t = ((key[i]).hashCode());
t ^= (value[i]);
h += t;
i++;
}
if (containsNullKey)
h += (value[n]);
return h;
}
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
final K key[] = this.key;
final byte value[] = this.value;
final MapIterator i = new MapIterator();
s.defaultWriteObject();
for (int j = size, e; j-- != 0;) {
e = i.nextEntry();
s.writeObject(key[e]);
s.writeByte(value[e]);
}
}
@SuppressWarnings("unchecked")
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
s.defaultReadObject();
n = arraySize(size, f);
maxFill = maxFill(n, f);
mask = n - 1;
final K key[] = this.key = (K[]) new Object[n + 1];
final byte value[] = this.value = new byte[n + 1];
K k;
byte v;
for (int i = size, pos; i-- != 0;) {
k = (K) s.readObject();
v = s.readByte();
if (((k) == null)) {
pos = n;
containsNullKey = true;
} else {
pos = (it.unimi.dsi.fastutil.HashCommon.mix((k).hashCode())) & mask;
while (!((key[pos]) == null))
pos = (pos + 1) & mask;
}
key[pos] = k;
value[pos] = v;
}
if (ASSERTS)
checkTable();
}
private void checkTable() {
}
}