@SuppressWarnings({"rawtypes", "unchecked"}) Entry<K, V> removeMapping(Object o) { if (!(o instanceof Map.Entry)) { return null; } Entry[] tab = getTable(); Map.Entry entry = (Map.Entry) o; Object k = maskNull(entry.getKey()); int h = HashMap.hash(k.hashCode()); int i = indexFor(h, tab.length); Entry<K, V> prev = tab[i]; Entry<K, V> e = prev; while (e != null) { Entry<K, V> next = e.next; if (h == e.hash && e.equals(entry)) { modCount++; size--; if (prev == e) { tab[i] = next; } else { prev.next = next; } return e; } prev = e; e = next; } return null; }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override public V remove(Object key) { Object k = maskNull(key); int h = HashMap.hash(k.hashCode()); Entry[] tab = getTable(); int i = indexFor(h, tab.length); Entry<K, V> prev = tab[i]; Entry<K, V> e = prev; while (e != null) { Entry<K, V> next = e.next; if (h == e.hash && eq(k, e.get())) { modCount++; size--; if (prev == e) { tab[i] = next; } else { prev.next = next; } return e.value; } prev = e; e = next; } return null; }
@SuppressWarnings({"unchecked", "rawtypes", "unused"}) @Override public V put(K key, V value) { K k = (K) maskNull(key); int h = HashMap.hash(k.hashCode()); Entry[] tab = getTable(); int i = indexFor(h, tab.length); for (Entry<K, V> e = tab[i]; e != null; e = e.next) { if (h == e.hash && eq(k, e.get())) { V oldValue = e.value; if (value != oldValue) { e.value = value; } return oldValue; } } modCount++; Entry<K, V> e = tab[i]; // tab[i] = new Entry<K,V>(k, value, queue, h, e); if (++size >= threshold) { resize(tab.length * 2); } return null; }
Entry<K, V> getEntry(Object key) { Object k = maskNull(key); int h = HashMap.hash(k); Entry[] tab = getTable(); int index = indexFor(h, tab.length); Entry<K, V> e = tab[index]; while (e != null && !(e.hash == h && eq(k, e.get()))) e = e.next; return e; }
@SuppressWarnings({"rawtypes", "unchecked"}) Entry<K, V> getEntry(Object key) { Object k = maskNull(key); int h = HashMap.hash(k.hashCode()); Entry[] tab = getTable(); int index = indexFor(h, tab.length); Entry<K, V> e = tab[index]; while (e != null && !(e.hash == h && eq(k, e.get()))) { e = e.next; } return e; }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override public V get(Object key) { Object k = maskNull(key); int h = HashMap.hash(k.hashCode()); Entry[] tab = getTable(); int index = indexFor(h, tab.length); Entry<K, V> e = tab[index]; while (e != null) { if (e.hash == h && eq(k, e.get())) { return e.value; } e = e.next; } return null; }