question: protected void evictWithFreezer ( ) { int elemsToRemovePreCheck = elementsToRemove ( ) ; if ( elemsToRemovePreCheck <= 0 ) { return ; } int i = 0 ; Set < Entry < K , AccessTimeObjectHolder < V > > > entrySet = objects . entrySet ( ) ; int size = entrySet . size ( ) ; ArrayList < HolderFreezer < K , V > > toCheckL = new ArrayList < > ( size ) ; for ( Entry < K , AccessTimeObjectHolder < V > > entry : entrySet ) { if ( i == size ) { break ; } K key = entry . getKey ( ) ; AccessTimeObjectHolder < V > holder = entry . getValue ( ) ; long frozenValue = evictionClass . getFreezeValue ( key , holder ) ; HolderFreezer < K , V > frozen = new HolderFreezer < > ( key , holder , frozenValue ) ; toCheckL . add ( i , frozen ) ; i ++ ; } @ SuppressWarnings ( "unchecked" ) HolderFreezer < K , V > [ ] toCheck = toCheckL . toArray ( new HolderFreezer [ toCheckL . size ( ) ] ) ; Arrays . sort ( toCheck , evictionClass . evictionComparator ( ) ) ; int removedCount = 0 ; int elemsToRemove = elementsToRemove ( ) ; for ( HolderFreezer < K , V > entryToRemove : toCheck ) { K key = entryToRemove . getKey ( ) ; V oldValue = remove ( key ) ; if ( oldValue != null ) { ++ removedCount ; if ( expiryNotification ) evictedElements . put ( key , oldValue ) ; if ( removedCount >= elemsToRemove ) break ; } } evictionCount . addAndGet ( removedCount ) ; statisticsCalculator . incrementRemoveCount ( removedCount ) ; evictionRateCounter . registerEvents ( millisEstimator . seconds ( ) , removedCount ) ; }
target:  Evict optimally according to eviction policy by inspecting ALL Cache entries. The values to be compared are frozen, so that comparisons are consistent during the eviction.  