public int remove(final int key) { final int[] entries = this.entries; final int missingValue = this.missingValue; @DoNotSub final int mask = entries.length - 1; @DoNotSub int keyIndex = Hashing.evenHash(key, mask); int oldValue = missingValue; while (entries[keyIndex + 1] != missingValue) { if (entries[keyIndex] == key) { oldValue = entries[keyIndex + 1]; entries[keyIndex + 1] = missingValue; size--; compactChain(keyIndex); break; } keyIndex = next(keyIndex, mask); } return oldValue; }
public int remove(final int key) { final int[] entries = this.entries; final int missingValue = this.missingValue; @DoNotSub final int mask = entries.length - 1; @DoNotSub int keyIndex = Hashing.evenHash(key, mask); int oldValue = missingValue; while (entries[keyIndex + 1] != missingValue) { if (entries[keyIndex] == key) { oldValue = entries[keyIndex + 1]; entries[keyIndex + 1] = missingValue; size--; compactChain(keyIndex); break; } keyIndex = next(keyIndex, mask); } return oldValue; }
public int remove(final int key) { final int[] entries = this.entries; final int missingValue = this.missingValue; @DoNotSub final int mask = entries.length - 1; @DoNotSub int index = Hashing.evenHash(key, mask); int oldValue = missingValue; int candidateKey; while ((candidateKey = entries[index]) != missingValue) { if (candidateKey == key) { @DoNotSub final int valueIndex = index + 1; oldValue = entries[valueIndex]; entries[index] = missingValue; entries[valueIndex] = missingValue; size--; compactChain(index); break; } index = next(index, mask); } return oldValue; }