Skip to content

Instantly share code, notes, and snippets.

@lichenbo
Created July 14, 2013 07:20
Show Gist options
  • Save lichenbo/5993490 to your computer and use it in GitHub Desktop.
Save lichenbo/5993490 to your computer and use it in GitHub Desktop.
public V put(K key, V value) {
if (key == null)
return putForNullKey(value);
int hash = hash(key.hashCode());
int i = indexFor(hash, table.length);
for (Entry<K,V> e = table[i]; e != null; e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
V oldValue = e.value;
e.value = value;
e.recordAccess(this);
return oldValue;
}
}
modCount++;
addEntry(hash, key, value, i);
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment