Class LazyRemovalList<T>
java.lang.Object
org.jgroups.util.LazyRemovalList<T>
- Type Parameters:
T- T
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.
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear(boolean force) voidAdds all value which have not been marked as removable to the returned setprintCache(LazyRemovalList.Printable<T> print_function) voidvoidRemoves elements marked as removablevoidremoveMarkedElements(boolean force) Removes elements marked as removableintsize()toString()
-
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 cachemax_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
-
get
-
forEach
-
remove
-
clear
public void clear(boolean force) -
nonRemovedValues
-
size
public int size() -
printCache
-
printCache
-
toString
-
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
-