boolean () { boolean removed = false; KeyReference<K,V> keyReference; //noinspection unchecked while ((keyReference = (KeyReference<K, V>)myKeyQueue.poll()) != null) { ValueReference<K, V> valueReference = keyReference.getValueReference(); removed |= myMap.remove(keyReference, valueReference); } ValueReference<K,V> valueReference; //noinspection unchecked while ((valueReference = (ValueReference<K, V>)myValueQueue.poll()) != null) { keyReference = valueReference.getKeyReference(); removed |= myMap.remove(keyReference, valueReference); } return removed; }