Class LazyRemovalList<T>

java.lang.Object
org.jgroups.util.LazyRemovalList<T>
Type Parameters:
T - T

public class LazyRemovalList<T> extends Object
List which doesn't remove elements on remove(), removeAll() or retainAll(), but only removes elements when a configurable size limit has been exceeded. In that case, all elements marked as removable and older than a configurable time are evicted. Elements are marked as removable by remove(), removeAll() and retainAll(). When an elements is marked as removable, but later reinserted, the mark is removed.
Note that methods get() and remove() iterate through the list (linear cost), so large lists will be slow.
Since:
5.4.4
Author:
Bela Ban
  • Constructor Details

    • LazyRemovalList

      public LazyRemovalList()
    • LazyRemovalList

      public LazyRemovalList(int max_elements, long max_age)
      Creates a new instance
      Parameters:
      max_elements - The max number of elements in the cache
      max_age - The max age (in ms) an entry can have before it is considered expired (and can be removed on the next sweep)
  • Method Details

    • add

      public boolean add(T val)
    • get

      public T get(T val)
    • forEach

      public void forEach(Consumer<T> c)
    • remove

      public void remove(T val)
    • clear

      public void clear(boolean force)
    • nonRemovedValues

      public List<T> nonRemovedValues()
      Adds all value which have not been marked as removable to the returned set
      Returns:
    • size

      public int size()
    • printCache

      public String printCache()
    • printCache

      public String printCache(LazyRemovalList.Printable<T> print_function)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • removeMarkedElements

      public void removeMarkedElements(boolean force)
      Removes elements marked as removable
      Parameters:
      force - If set to true, all elements marked as 'removable' will get removed, regardless of expiration
    • removeMarkedElements

      public void removeMarkedElements()
      Removes elements marked as removable