Package test

Class LFU

All Implemented Interfaces:
CacheReplacementPolicy

public class LFU extends Object implements CacheReplacementPolicy
  • Constructor Details

    • LFU

      public LFU()
  • Method Details

    • getWordsByOrder

      public LinkedHashMap<String,Integer> getWordsByOrder()
    • add

      public void add(String word)
      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:
      add in interface CacheReplacementPolicy
      Parameters:
      word - Add a word to the map
    • remove

      public String remove()
      The remove function removes the least frequently used word from the cache.
      Specified by:
      remove in interface CacheReplacementPolicy
      Returns:
      The string that was removed