Class CopyOnWriteSortedCache<T extends Comparable<T>>

java.lang.Object
com.atlassian.jira.util.collect.CopyOnWriteSortedCache<T>
Type Parameters:
T - the element type.
All Implemented Interfaces:
Iterable<T>

public class CopyOnWriteSortedCache<T extends Comparable<T>> extends Object implements Iterable<T>
Simple copy-on-write ordered cache with Set semantics. This implementation supports add/remove and replace all of elements.

Note that because this implementation uses JVM-local locks, it is unsuitable for use in a clustered environment. It should therefore not be used by core JIRA for data that needs to be consistent across the cluster.

  • Constructor Details

    • CopyOnWriteSortedCache

      public CopyOnWriteSortedCache(Iterable<T> elements)
  • Method Details

    • add

      public T add(T t)
    • remove

      public void remove(T t)
    • replaceAll

      public void replaceAll(Iterable<T> elements)
    • asList

      public List<T> asList()
      An unmodifiable List view of the underlying data that does not change.
      Returns:
      a List containing all the elements as at the time the call was made.
    • asSortedSet

      public SortedSet<T> asSortedSet()
      An unmodifiable SortedSet view of the underlying data that does not change.
      Returns:
      a SortedSet containing all the elements as at the time the call was made.
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends Comparable<T>>