public class SmallestElementSet<E extends Comparable<E>> extends TreeSet<E>
TreeSet
that keeps only the smallest elements, up to a specified number of maximum elements.Modifier and Type | Field and Description |
---|---|
private int |
maxElementCount |
(package private) static long |
serialVersionUID |
Constructor and Description |
---|
SmallestElementSet(int maxElementCount) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E element) |
boolean |
addAll(Collection<? extends E> collection) |
ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, subSet, subSet, tailSet, tailSet
equals, hashCode, removeAll
containsAll, retainAll, toArray, toArray, toString
static final long serialVersionUID
private final int maxElementCount
public SmallestElementSet(int maxElementCount)
maxElementCount
- Maximum number of elements the set will keeppublic boolean add(E element)
add
in interface Collection<E extends Comparable<E>>
add
in interface Set<E extends Comparable<E>>
add
in class TreeSet<E extends Comparable<E>>
true
if this set was modified by the operationpublic boolean addAll(Collection<? extends E> collection)
addAll
in interface Collection<E extends Comparable<E>>
addAll
in interface Set<E extends Comparable<E>>
addAll
in class TreeSet<E extends Comparable<E>>