/** * Special version of remove for EntrySet. */ Entry removeMapping(Object o) { if (!(o instanceof Entry)) return null; Entry entry = (Entry) o; Object key = entry.getKey(); int hash = (key == null) ? 0 : hash(hashingStrategy.hashCode(key)); int i = indexFor(hash, table.length); Entry prev = table[i]; Entry e = prev; while (e != null) { Entry next = e.next; if (e.hash == hash && e.equals(entry)) { modCount++; size--; if (prev == e) table[i] = next; else prev.next = next; e.recordRemoval(this); return e; } prev = e; e = next; } return e; }
/** * Removes and returns the entry associated with the specified key in the IntHashMap. Returns null * if the IntHashMap contains no mapping for this key. */ Entry removeEntryForKey(Object key) { int hash = (key == null) ? 0 : hash(hashingStrategy.hashCode(key)); int i = indexFor(hash, table.length); Entry prev = table[i]; Entry e = prev; while (e != null) { Entry next = e.next; Object k; if (e.hash == hash && ((k = e.key) == key || (key != null && hashingStrategy.equals(k, key)))) { modCount++; size--; if (prev == e) table[i] = next; else prev.next = next; e.recordRemoval(this); return e; } prev = e; e = next; } return e; }