/** * Read the value of an entry under lock. Called if the value field appears * to be {@code null}. */ private V readValueUnderLock(final IntHashEntry<V> entry) { lock(); try { return entry.value; } finally { unlock(); } }
/** * Read the value of an entry under lock. Called if the value field appears * to be {@code null}. */ private V readValueUnderLock(final IntHashEntry<V> entry) { lock(); try { return entry.value; } finally { unlock(); } }
/** * Read the value of an entry under lock. Called if the value field appears * to be {@code null}. */ private V readValueUnderLock(final IntHashEntry<V> entry) { lock(); try { return entry.value; } finally { unlock(); } }
@Override public void clear() { if (count != 0) { // read-volatile lock(); try { final IntHashEntry<?>[] t = table; for (int i = 0; i < t.length; i++) { t[i] = null; } ++modCount; count = 0; } finally { unlock(); } } }
@Override public void clear() { if (count != 0) { // read-volatile lock(); try { final IntHashEntry<?>[] t = table; for (int i = 0; i < t.length; i++) { t[i] = null; } ++modCount; count = 0; } finally { unlock(); } } }
@Override public void clear() { if (count != 0) { // read-volatile lock(); try { final IntHashEntry<?>[] t = table; for (int i = 0; i < t.length; i++) { t[i] = null; } ++modCount; count = 0; } finally { unlock(); } } }
protected V removeCore(final int key, @Nullable final V value) { lock(); try { final int newCount = count - 1; final IntHashEntry<V>[] t = table; final int index = key & (table.length - 1); IntHashEntry<V> entry = t[index]; while (entry != null && entry.key != key) { entry = entry.next; } if (entry != null) { final V oldValue = entry.value; if (value == null || value.equals(oldValue)) { ++modCount; IntHashEntry<V> newFirst = t[index]; for (IntHashEntry<V> p = newFirst; p != entry; p = p.next) { newFirst = new IntHashEntry<>(p.key, newFirst, p.value); } t[index] = newFirst; count = newCount; return oldValue; } } return null; } finally { unlock(); } }
protected V removeCore(final int key, @Nullable final V value) { lock(); try { final int newCount = count - 1; final IntHashEntry<V>[] t = table; final int index = key & (table.length - 1); IntHashEntry<V> entry = t[index]; while (entry != null && entry.key != key) { entry = entry.next; } if (entry != null) { final V oldValue = entry.value; if (value == null || value.equals(oldValue)) { ++modCount; IntHashEntry<V> newFirst = t[index]; for (IntHashEntry<V> p = newFirst; p != entry; p = p.next) { newFirst = new IntHashEntry<>(p.key, newFirst, p.value); } t[index] = newFirst; count = newCount; return oldValue; } } return null; } finally { unlock(); } }
protected V removeCore(final int key, @Nullable final V value) { lock(); try { final int newCount = count - 1; final IntHashEntry<V>[] t = table; final int index = key & (table.length - 1); IntHashEntry<V> entry = t[index]; while (entry != null && entry.key != key) { entry = entry.next; } if (entry != null) { final V oldValue = entry.value; if (value == null || value.equals(oldValue)) { ++modCount; IntHashEntry<V> newFirst = t[index]; for (IntHashEntry<V> p = newFirst; p != entry; p = p.next) { newFirst = new IntHashEntry<>(p.key, newFirst, p.value); } t[index] = newFirst; count = newCount; return oldValue; } } return null; } finally { unlock(); } }
@Override public boolean replace(final int key, @NotNull final V oldValue, @NotNull final V newValue) { VerifyArgument.notNull(oldValue, "oldValue"); VerifyArgument.notNull(newValue, "newValue"); lock(); try { IntHashEntry<V> entry = getFirst(key); while (entry != null && entry.key != key) { entry = entry.next; } if (entry != null && oldValue.equals(entry.value)) { entry.value = newValue; return true; } return false; } finally { unlock(); } }
@Override public boolean replace(final int key, @NotNull final V oldValue, @NotNull final V newValue) { VerifyArgument.notNull(oldValue, "oldValue"); VerifyArgument.notNull(newValue, "newValue"); lock(); try { IntHashEntry<V> entry = getFirst(key); while (entry != null && entry.key != key) { entry = entry.next; } if (entry != null && oldValue.equals(entry.value)) { entry.value = newValue; return true; } return false; } finally { unlock(); } }
@Override public boolean replace(final int key, @NotNull final V oldValue, @NotNull final V newValue) { VerifyArgument.notNull(oldValue, "oldValue"); VerifyArgument.notNull(newValue, "newValue"); lock(); try { IntHashEntry<V> entry = getFirst(key); while (entry != null && entry.key != key) { entry = entry.next; } if (entry != null && oldValue.equals(entry.value)) { entry.value = newValue; return true; } return false; } finally { unlock(); } }