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>,java.lang.Iterable<E>
public class TreeSet<E> extends AbstractSortedSet<E>
TreeSetis an implementation ofSortedSetbacked by aTreeMap.
-
-
Field Summary
Fields Modifier and Type Field Description protected static TreeSetEMPTYprivate RedBlackTree<E,E>redBlackTreeprivate Tree<E,E>tree
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull 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, ornullif the default ordering is used.booleancontains(E value)Returns true if the value exists in this set.@NotNull SortedSet<E>drop(int number)Returns a set containing all elements in this set, excluding the firstnumberof elements.static <E> @NotNull TreeSet<E>empty()static <E> @NotNull BuilderFactory<E,TreeSet<E>>factory(java.util.Comparator<? super E> ordering)Efirst()Returns the first element in the set ornullof the set is empty.@NotNull SortedSet<E>from(E value, boolean inclusive)Returns the bottom of the set starting from the key specified.@NotNull java.util.Iterator<E>iterator()Elast()Returns the last element in the set ornullof the set is empty.@NotNull SortedSet<E>range(E from, boolean fromInclusive, E to, boolean toInclusive)Returns a subset of the set between thefromandtokeys specified.@NotNull TreeSet<E>remove(E value)Removes the specified value from the set if it exists.intsize()Returns the size of the collection.@NotNull SortedSet<E>take(int number)Returns a set containing the firstnumberof elements from this set.@NotNull SortedSet<E>to(E value, boolean inclusive)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 com.github.andrewoma.dexx.collection.Traversable
forEach, isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
-
-
-
Method Detail
-
factory
@NotNull public static <E> @NotNull BuilderFactory<E,TreeSet<E>> factory(java.util.Comparator<? super E> ordering)
-
empty
@NotNull public static <E> @NotNull TreeSet<E> empty()
-
comparator
public java.util.Comparator<? super E> comparator()
Description copied from interface:SortedSetReturns the comparator associated with this map, ornullif the default ordering is used.
-
add
@NotNull public @NotNull TreeSet<E> add(E value)
Description copied from interface:SetReturns a set that adds the specified value if it doesn't already exist in this set.
-
remove
@NotNull public @NotNull TreeSet<E> remove(E value)
Description copied from interface:SetRemoves the specified value from the set if it exists.
-
contains
public boolean contains(E value)
Description copied from interface:SetReturns true if the value exists in this set.
-
size
public int size()
Description copied from interface:TraversableReturns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
sizein interfaceTraversable<E>- Overrides:
sizein classAbstractTraversable<E>
-
first
@Nullable public E first()
Description copied from interface:SortedSetReturns the first element in the set ornullof the set is empty.
-
last
@Nullable public E last()
Description copied from interface:SortedSetReturns the last element in the set ornullof the set is empty.
-
iterator
@NotNull public @NotNull java.util.Iterator<E> iterator()
-
drop
@NotNull public @NotNull SortedSet<E> drop(int number)
Description copied from interface:SortedSetReturns a set containing all elements in this set, excluding the firstnumberof elements.
-
take
@NotNull public @NotNull SortedSet<E> take(int number)
Description copied from interface:SortedSetReturns a set containing the firstnumberof elements from this set.
-
from
@NotNull public @NotNull SortedSet<E> from(@NotNull E value, boolean inclusive)
Description copied from interface:SortedSetReturns the bottom of the set starting from the key specified.
-
to
@NotNull public @NotNull SortedSet<E> to(@NotNull E value, boolean inclusive)
Description copied from interface:SortedSetReturns 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:SortedSetReturns a subset of the set between thefromandtokeys 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
-
-