public class TreeSet<E> extends AbstractSortedSet<E>
TreeSet is an implementation of SortedSet backed by a TreeMap.| Constructor and Description |
|---|
TreeSet() |
TreeSet(java.util.Comparator<? super E> ordering) |
| Modifier and Type | Method and Description |
|---|---|
TreeSet<E> |
add(E value)
Returns a set that adds the specified value if it doesn't already exist in this set.
|
java.util.Comparator<? super E> |
comparator()
Returns the comparator associated with this map, or
null if the default ordering is used. |
boolean |
contains(E value)
Returns true if the value exists in this set.
|
SortedSet<E> |
drop(int number)
Returns a set containing all elements in this set, excluding the first
number of elements. |
static <E> TreeSet<E> |
empty() |
static <E> BuilderFactory<E,TreeSet<E>> |
factory(java.util.Comparator<? super E> ordering) |
E |
first()
Returns the first element in the set or
null of the set is empty. |
SortedSet<E> |
from(E value,
boolean inclusive)
Returns the bottom of the set starting from the key specified.
|
java.util.Iterator<E> |
iterator() |
E |
last()
Returns the last element in the set or
null of the set is empty. |
SortedSet<E> |
range(E from,
boolean fromInclusive,
E to,
boolean toInclusive)
Returns a subset of the set between the
from and to keys specified. |
TreeSet<E> |
remove(E value)
Removes the specified value from the set if it exists.
|
int |
size()
Returns the size of the collection.
|
SortedSet<E> |
take(int number)
Returns a set containing the first
number of elements from this set. |
SortedSet<E> |
to(E value,
boolean inclusive)
Returns the top of the set up until the key specified.
|
asSortedSetasSet, equals, hashCodeforEachisEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSetprotected static final TreeSet EMPTY
public TreeSet()
public TreeSet(java.util.Comparator<? super E> ordering)
@NotNull public static <E> BuilderFactory<E,TreeSet<E>> factory(java.util.Comparator<? super E> ordering)
@NotNull public static <E> TreeSet<E> empty()
public java.util.Comparator<? super E> comparator()
SortedSetnull if the default ordering is used.@NotNull public TreeSet<E> add(E value)
Set@NotNull public TreeSet<E> remove(E value)
Setpublic boolean contains(E value)
Setpublic int size()
TraversableWarning: infinite collections are possible, as are collections that require traversal to calculate the size.
size in interface Traversable<E>size in class AbstractTraversable<E>@Nullable public E first()
SortedSetnull of the set is empty.@Nullable public E last()
SortedSetnull of the set is empty.@NotNull public java.util.Iterator<E> iterator()
@NotNull public SortedSet<E> drop(int number)
SortedSetnumber of elements.@NotNull public SortedSet<E> take(int number)
SortedSetnumber of elements from this set.@NotNull public SortedSet<E> from(@NotNull E value, boolean inclusive)
SortedSet@NotNull public SortedSet<E> to(@NotNull E value, boolean inclusive)
SortedSet@NotNull public SortedSet<E> range(@NotNull E from, boolean fromInclusive, @NotNull E to, boolean toInclusive)
SortedSetfrom and to keys specified.fromInclusive - if true, the key will be included in the result, otherwise it will be excludedtoInclusive - if true, the key will be included in the result, otherwise it will be excluded