Class LimitedSortedSet<E>

java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingCollection<E>
com.google.common.collect.ForwardingSet<E>
com.google.common.collect.ForwardingSortedSet<E>
sonia.scm.collect.LimitedSortedSet<E>
Type Parameters:
E -
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, SortedSet<E>

public class LimitedSortedSet<E> extends com.google.common.collect.ForwardingSortedSet<E>
A sorted set which is limited to a specified maximum size. If the maximum size is reached the last element is removed from the set.
Since:
1.32
  • Constructor Summary

    Constructors
    Constructor
    Description
    LimitedSortedSet(int maxSize)
    Constructs a new set with the specified maximum.
    LimitedSortedSet(Comparator<E> comparator, int maxSize)
    Constructs a new set with the specified comparator and maximum.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(E o)
     
    boolean
    addAll(Collection<? extends E> c)
     
    protected SortedSet<E>
    Returns the underlying delegate set.

    Methods inherited from class com.google.common.collect.ForwardingSortedSet

    comparator, first, headSet, last, standardContains, standardRemove, standardSubSet, subSet, tailSet

    Methods inherited from class com.google.common.collect.ForwardingSet

    equals, hashCode, standardEquals, standardHashCode, standardRemoveAll

    Methods inherited from class com.google.common.collect.ForwardingCollection

    clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContainsAll, standardIsEmpty, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray

    Methods inherited from class com.google.common.collect.ForwardingObject

    toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.Set

    clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

    Methods inherited from interface java.util.SortedSet

    spliterator
  • Constructor Details

    • LimitedSortedSet

      public LimitedSortedSet(int maxSize)
      Constructs a new set with the specified maximum.
      Parameters:
      maxSize - maximum size of the set
    • LimitedSortedSet

      public LimitedSortedSet(Comparator<E> comparator, int maxSize)
      Constructs a new set with the specified comparator and maximum.
      Parameters:
      comparator - comparator to order the set
      maxSize - maximum size of the set
  • Method Details

    • add

      public boolean add(E o)
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface Set<E>
      Overrides:
      add in class com.google.common.collect.ForwardingCollection<E>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface Set<E>
      Overrides:
      addAll in class com.google.common.collect.ForwardingCollection<E>
    • delegate

      protected SortedSet<E> delegate()
      Returns the underlying delegate set.
      Specified by:
      delegate in class com.google.common.collect.ForwardingSortedSet<E>
      Returns:
      delegate set