Class TreeSet<E>
java.lang.Object
com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractIterable<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractSet<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractSortedSet<E>
com.github.andrewoma.dexx.collection.TreeSet<E>
- All Implemented Interfaces:
Iterable<E>
,Set<E>
,SortedSet<E>
,Traversable<E>
,Iterable<E>
TreeSet
is an implementation of SortedSet
backed by a TreeMap
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a set that adds the specified value if it doesn't already exist in this set.Comparator
<? super E> Returns the comparator associated with this map, ornull
if the default ordering is used.boolean
Returns true if the value exists in this set.drop
(int number) Returns a set containing all elements in this set, excluding the firstnumber
of elements.static <E> @NotNull TreeSet
<E> empty()
static <E> @NotNull BuilderFactory
<E, TreeSet<E>> factory
(Comparator<? super E> ordering) first()
Returns the first element in the set ornull
of the set is empty.Returns the bottom of the set starting from the key specified.iterator()
last()
Returns the last element in the set ornull
of the set is empty.Returns a subset of the set between thefrom
andto
keys specified.Removes the specified value from the set if it exists.int
size()
Returns the size of the collection.take
(int number) Returns a set containing the firstnumber
of elements from this set.Returns the top of the set up until the key specified.Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractSortedSet
asSortedSet
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractSet
asSet, equals, hashCode
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractIterable
forEach
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable
isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable
forEach, isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
Field Details
-
tree
-
redBlackTree
-
EMPTY
-
-
Constructor Details
-
TreeSet
public TreeSet() -
TreeSet
-
TreeSet
-
-
Method Details
-
factory
@NotNull public static <E> @NotNull BuilderFactory<E,TreeSet<E>> factory(Comparator<? super E> ordering) -
empty
-
comparator
Description copied from interface:SortedSet
Returns the comparator associated with this map, ornull
if the default ordering is used. -
add
Description copied from interface:Set
Returns a set that adds the specified value if it doesn't already exist in this set. -
remove
Description copied from interface:Set
Removes the specified value from the set if it exists. -
contains
Description copied from interface:Set
Returns true if the value exists in this set. -
size
public int size()Description copied from interface:Traversable
Returns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
size
in interfaceTraversable<E>
- Overrides:
size
in classAbstractTraversable<E>
-
first
Description copied from interface:SortedSet
Returns the first element in the set ornull
of the set is empty. -
last
Description copied from interface:SortedSet
Returns the last element in the set ornull
of the set is empty. -
iterator
-
drop
Description copied from interface:SortedSet
Returns a set containing all elements in this set, excluding the firstnumber
of elements. -
take
Description copied from interface:SortedSet
Returns a set containing the firstnumber
of elements from this set. -
from
Description copied from interface:SortedSet
Returns the bottom of the set starting from the key specified. -
to
Description copied from interface:SortedSet
Returns the top of the set up until the key specified. -
range
@NotNull public @NotNull SortedSet<E> range(@NotNull E from, boolean fromInclusive, @NotNull E to, boolean toInclusive) Description copied from interface:SortedSet
Returns a subset of the set between thefrom
andto
keys specified.- Parameters:
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
-