java.lang.Object
model.logic.server.dictionary.LFU
- All Implemented Interfaces:
CacheReplacementPolicy
-
Constructor Summary
ConstructorsConstructorDescriptionLFU()The LFU function takes in a string and adds it to the LinkedHashMap words. -
Method Summary
-
Constructor Details
-
LFU
public LFU()The LFU function takes in a string and adds it to the LinkedHashMap words. If the word is already in the map, then its value is incremented by 1.
-
-
Method Details
-
add
The add function adds a word to the map. If the word is already in the map, it increments its count by 1. Otherwise, it adds a new entry with value 1.- Specified by:
addin interfaceCacheReplacementPolicy- Parameters:
word- 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 key with the lowest value
-