Class EvictingMap<K,V>

java.lang.Object
de.florianmichael.rclasses.pattern.evicting.EvictingMap<K,V>
Type Parameters:
K - The type of the key.
V - The type of the value.

public final class EvictingMap<K,V> extends Object
Implementation of an evicting map. This map will remove the first entry if the map is full.
  • Constructor Details

    • EvictingMap

      public EvictingMap()
      Dummy constructor.
    • EvictingMap

      public EvictingMap(Map<K,V> map, int maxSize)
      Creates a new evicting map.
      Parameters:
      map - The map.
      maxSize - The maximum size of the map.
  • Method Details

    • put

      public boolean put(K key, V value)
      Puts a key and a value into the map. If the map is full, the first entry will be removed. Returns true if the map was full.
      Parameters:
      key - The key.
      value - The value.
      Returns:
      True if the map was full.
    • isFull

      public boolean isFull()
      Returns:
      True if the map is full.
    • getNormalMap

      public Map<K,V> getNormalMap()
    • getMaxSize

      public int getMaxSize()