com.discoversites.util.collections
Class BoundedTreeSet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.TreeSet<T>
com.discoversites.util.collections.BoundedTreeSet<T>
- Type Parameters:
T
- The type of element to be stored the BoundedTreeSet
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable<T>, Collection<T>, NavigableSet<T>, Set<T>, SortedSet<T>
public class BoundedTreeSet<T>
- extends TreeSet<T>
An implementation of TreeSet that restricts the size of the tree to the size
specified at construction. If adding an element to BoundedTreeSet results in
the size of the set being maxSize + 1 then the element at the last position is
removed. If maxSize is not specified then Integer.MAX_VALUE
is used.
BoundedTreeSet is backed by the standard Java TreeSet implementation.
- Author:
- Mark
- See Also:
- Serialized Form
Methods inherited from class java.util.TreeSet |
ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, subSet, subSet, tailSet, tailSet |
BoundedTreeSet
public BoundedTreeSet()
BoundedTreeSet
public BoundedTreeSet(Collection<? extends T> c)
- Parameters:
c
- A Collection
of elements to be added to this BoundedTreeSet
BoundedTreeSet
public BoundedTreeSet(Comparator<? super T> c)
- Parameters:
c
- A Comparator
implementation to be used for sorting the elements in this BoundedTreeSet
BoundedTreeSet
public BoundedTreeSet(SortedSet<T> set)
- Parameters:
set
- A SortedSet
containing pre-sorted objects to be added to this BoundedTreeSet
BoundedTreeSet
public BoundedTreeSet(int maxSize,
Collection<? extends T> c)
- Parameters:
maxSize
- The max size of this BoundedTreeSetc
- A Collection
of elements to be added to this BoundedTreeSet
BoundedTreeSet
public BoundedTreeSet(int maxSize,
Comparator<? super T> comparator)
- Parameters:
maxSize
- The max size of this BoundedTreeSetcomparator
- A Comparator
implementation to be used for sorting the elements in this BoundedTreeSet
BoundedTreeSet
public BoundedTreeSet(int maxSize,
SortedSet<T> s)
- Parameters:
maxSize
- The max size of this BoundedTreeSets
- A SortedSet
containing pre-sorted objects to be added to this BoundedTreeSet
BoundedTreeSet
public BoundedTreeSet(int maxSize)
- Parameters:
maxSize
- The max size of this BoundedTreeSet
add
public boolean add(T element)
- Specified by:
add
in interface Collection<T>
- Specified by:
add
in interface Set<T>
- Overrides:
add
in class TreeSet<T>
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAll
in interface Collection<T>
- Specified by:
addAll
in interface Set<T>
- Overrides:
addAll
in class TreeSet<T>