Class BoundedTreeSet<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, NavigableSet<E>, SequencedCollection<E>, SequencedSet<E>, Set<E>, SortedSet<E>

public class BoundedTreeSet<E> extends TreeSet<E>
A TreeSet that ensures it never grows beyond a max size. last() is removed if the size() get's bigger then getMaxSize()
See Also:
  • Constructor Details

    • BoundedTreeSet

      public BoundedTreeSet(int maxSize)
    • BoundedTreeSet

      public BoundedTreeSet(int maxSize, Collection<? extends E> c)
    • BoundedTreeSet

      public BoundedTreeSet(int maxSize, Comparator<? super E> c)
    • BoundedTreeSet

      public BoundedTreeSet(int maxSize, SortedSet<E> s)
  • Method Details

    • getMaxSize

      public int getMaxSize()
    • setMaxSize

      public void setMaxSize(int max)
    • add

      public boolean add(E item)
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface Set<E>
      Overrides:
      add in class TreeSet<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 TreeSet<E>