boolean (Object o) { processQueue(); if (!(o instanceof Entry)) return false; //noinspection unchecked Entry<K, V> e = (Entry<K, V>)o; V ev = e.getValue(); // optimization: do not recreate the key HardKey key = myHardKeyInstance; boolean toRemove; try { key.set(e.getKey()); V hv = myMap.get(key); toRemove = hv == null ? ev == null && myMap.containsKey(key) : hv.equals(ev); if (toRemove) { myMap.remove(key); } } finally { key.clear(); } return toRemove; }