Class CircularPriorityQueue<K,V,SLK extends Keyed<K>>

java.lang.Object
org.mockserver.collections.CircularPriorityQueue<K,V,SLK>

public class CircularPriorityQueue<K,V,SLK extends Keyed<K>> extends Object
Author:
jamesdbloom
  • Constructor Details

    • CircularPriorityQueue

      public CircularPriorityQueue(int maxSize, Comparator<? super SLK> skipListComparator, Function<V,SLK> skipListKeyFunction, Function<V,K> mapKeyFunction)
  • Method Details

    • setMaxSize

      public void setMaxSize(int maxSize)
    • removePriorityKey

      public void removePriorityKey(V element)
    • addPriorityKey

      public void addPriorityKey(V element)
    • add

      public void add(V element)
    • replaceValue

      public boolean replaceValue(K key, V newValue)
      Replaces the value associated with the given key in place, preserving the element's position in insertionOrderQueue (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 element
      newValue - the replacement value
      Returns:
      true if the key was found and the value replaced
    • remove

      public boolean remove(V element)
    • size

      public int size()
    • stream

      public Stream<V> stream()
    • getByKey

      public Optional<V> getByKey(K key)
    • keyMap

      public Map<K,V> keyMap()
    • isEmpty

      public boolean isEmpty()
    • toSortedList

      public List<V> 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.