Package org.mockserver.collections
Class CircularPriorityQueue<K,V,SLK extends Keyed<K>>
java.lang.Object
org.mockserver.collections.CircularPriorityQueue<K,V,SLK>
- Author:
- jamesdbloom
-
Constructor Summary
ConstructorsConstructorDescriptionCircularPriorityQueue(int maxSize, Comparator<? super SLK> skipListComparator, Function<V, SLK> skipListKeyFunction, Function<V, K> mapKeyFunction) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddPriorityKey(V element) booleanisEmpty()keyMap()booleanvoidremovePriorityKey(V element) booleanreplaceValue(K key, V newValue) Replaces the value associated with the given key in place, preserving the element's position ininsertionOrderQueue(and therefore its eviction order).voidsetMaxSize(int maxSize) intsize()stream()Returns a cached, unmodifiable sorted snapshot of this queue's elements.
-
Constructor Details
-
CircularPriorityQueue
-
-
Method Details
-
setMaxSize
public void setMaxSize(int maxSize) -
removePriorityKey
-
addPriorityKey
-
add
-
replaceValue
Replaces the value associated with the given key in place, preserving the element's position ininsertionOrderQueue(and therefore its eviction order). The old value is swapped out of the insertion queue and byKey map and the new value takes its slot. Priority-sort keys are updated (old removed, new added).- Parameters:
key- the key that identifies the existing elementnewValue- the replacement value- Returns:
trueif the key was found and the value replaced
-
remove
-
size
public int size() -
stream
-
getByKey
-
keyMap
-
isEmpty
public boolean isEmpty() -
toSortedList
Returns a cached, unmodifiable sorted snapshot of this queue's elements. The snapshot is rebuilt lazily when any mutation nulls the cache.Eventually-consistent under concurrent mutation: a call to this method concurrent with a control-plane mutation (add/remove/ reconcileFromBackend) may return a snapshot that does not yet reflect the in-flight mutation. This is the existing control-plane / data-plane concurrency contract — no lock is held on the matching hot path.
-