java.lang.Object
test.LFU
- All Implemented Interfaces:
CacheReplacementPolicy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe add function adds a word to the map.remove()The remove function removes the least frequently used word from the cache.
-
Constructor Details
-
LFU
public LFU()
-
-
Method Details
-
getWordsByOrder
-
add
The add function adds a word to the map. If the word is already in the map, it increments its frequency by 1. Otherwise, it adds a new entry with frequency 1.- Specified by:
addin interfaceCacheReplacementPolicy- Parameters:
word- Add a word to the map
-
remove
The remove function removes the least frequently used word from the cache.- Specified by:
removein interfaceCacheReplacementPolicy- Returns:
- The string that was removed
-