@Override void removeAt(int index) { short free = freeValue; short[] keys = set; int capacityMask = keys.length - 1; incrementModCount(); int indexToRemove = index; int indexToShift = indexToRemove; int shiftDistance = 1; while (true) { indexToShift = (indexToShift - 1) & capacityMask; short keyToShift; if ((keyToShift = keys[indexToShift]) == free) { break; } if (((SeparateKVShortKeyMixing.mix(keyToShift) - indexToShift) & capacityMask) >= shiftDistance) { keys[indexToRemove] = keyToShift; indexToRemove = indexToShift; shiftDistance = 1; } else { shiftDistance++; if (indexToShift == 1 + index) { throw new java.util.ConcurrentModificationException(); } } } keys[indexToRemove] = free; postRemoveHook(); }
@Override void rehash(int newCapacity) { int mc = modCount(); short free = freeValue; short[] keys = set; initForRehash(newCapacity); mc++; // modCount is incremented in initForRehash() short[] newKeys = set; int capacityMask = newKeys.length - 1; for (int i = keys.length - 1; i >= 0; i--) { short key; if ((key = keys[i]) != free) { int index; if (newKeys[index = SeparateKVShortKeyMixing.mix(key) & capacityMask] != free) { while (true) { if (newKeys[(index = (index - 1) & capacityMask)] == free) { break; } } } newKeys[index] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); }
@Override final void move(SeparateKVShortLHash hash) { int myMC = modCount(), hashMC = hash.modCount(); super.move(hash); if (myMC != modCount() || hashMC != hash.modCount()) throw new ConcurrentModificationException(); }
@Override final void copy(SeparateKVShortLHash hash) { int myMC = modCount(), hashMC = hash.modCount(); super.copy(hash); if (myMC != modCount() || hashMC != hash.modCount()) throw new ConcurrentModificationException(); }
@Override final void move(SeparateKVShortLHash hash) { int myMC = modCount(), hashMC = hash.modCount(); super.move(hash); if (myMC != modCount() || hashMC != hash.modCount()) throw new ConcurrentModificationException(); }
@Override final void copy(SeparateKVShortLHash hash) { int myMC = modCount(), hashMC = hash.modCount(); super.copy(hash); if (myMC != modCount() || hashMC != hash.modCount()) throw new ConcurrentModificationException(); }
@Override void rehash(int newCapacity) { int mc = modCount(); short free = freeValue; short[] keys = set; initForRehash(newCapacity); mc++; // modCount is incremented in initForRehash() short[] newKeys = set; int capacityMask = newKeys.length - 1; for (int i = keys.length - 1; i >= 0; i--) { short key; if ((key = keys[i]) != free) { int index; if (newKeys[index = SeparateKVShortKeyMixing.mix(key) & capacityMask] != free) { while (true) { if (newKeys[(index = (index - 1) & capacityMask)] == free) { break; } } } newKeys[index] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); }
@Override void removeAt(int index) { short free = freeValue; short[] keys = set; int capacityMask = keys.length - 1; incrementModCount(); int indexToRemove = index; int indexToShift = indexToRemove; int shiftDistance = 1; while (true) { indexToShift = (indexToShift - 1) & capacityMask; short keyToShift; if ((keyToShift = keys[indexToShift]) == free) { break; } if (((SeparateKVShortKeyMixing.mix(keyToShift) - indexToShift) & capacityMask) >= shiftDistance) { keys[indexToRemove] = keyToShift; indexToRemove = indexToShift; shiftDistance = 1; } else { shiftDistance++; if (indexToShift == 1 + index) { throw new java.util.ConcurrentModificationException(); } } } keys[indexToRemove] = free; postRemoveHook(); }