com.github.andrewoma.dexx.collection
Class TreeSet<E>

java.lang.Object
  extended by com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable<E>
      extended by com.github.andrewoma.dexx.collection.internal.base.AbstractIterable<E>
          extended by com.github.andrewoma.dexx.collection.internal.base.AbstractSet<E>
              extended by com.github.andrewoma.dexx.collection.internal.base.AbstractSortedSet<E>
                  extended by com.github.andrewoma.dexx.collection.TreeSet<E>
All Implemented Interfaces:
Set<E>, SortedSet<E>, Traversable<E>, Iterable<E>

public class TreeSet<E>
extends AbstractSortedSet<E>

TreeSet is an implementation of SortedSet backed by a TreeMap.


Field Summary
protected static TreeSet EMPTY
           
 
Constructor Summary
TreeSet()
           
TreeSet(Comparator<? super E> ordering)
           
 
Method Summary
 TreeSet<E> add(E value)
          Returns a set that adds the specified value if it doesn't already exist in this set.
 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(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.
 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.
 
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.Set
asSet
 
Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable
forEach, isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
 

Field Detail

EMPTY

protected static final TreeSet EMPTY
Constructor Detail

TreeSet

public TreeSet()

TreeSet

public TreeSet(Comparator<? super E> ordering)
Method Detail

factory

@NotNull
public static <E> BuilderFactory<E,TreeSet<E>> factory(Comparator<? super E> ordering)

empty

@NotNull
public static <E> TreeSet<E> empty()

comparator

public Comparator<? super E> comparator()
Description copied from interface: SortedSet
Returns the comparator associated with this map, or null if the default ordering is used.


add

@NotNull
public TreeSet<E> add(E value)
Description copied from interface: Set
Returns a set that adds the specified value if it doesn't already exist in this set.


remove

@NotNull
public TreeSet<E> remove(E value)
Description copied from interface: Set
Removes the specified value from the set if it exists.


contains

public boolean contains(E value)
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 interface Traversable<E>
Overrides:
size in class AbstractTraversable<E>

first

@Nullable
public E first()
Description copied from interface: SortedSet
Returns the first element in the set or null of the set is empty.


last

@Nullable
public E last()
Description copied from interface: SortedSet
Returns the last element in the set or null of the set is empty.


iterator

@NotNull
public Iterator<E> iterator()

drop

@NotNull
public SortedSet<E> drop(int number)
Description copied from interface: SortedSet
Returns a set containing all elements in this set, excluding the first number of elements.


take

@NotNull
public SortedSet<E> take(int number)
Description copied from interface: SortedSet
Returns a set containing the first number of elements from this set.


from

@NotNull
public SortedSet<E> from(@NotNull
                                 E value,
                                 boolean inclusive)
Description copied from interface: SortedSet
Returns the bottom of the set starting from the key specified.

Specified by:
from in interface SortedSet<E>
Overrides:
from in class AbstractSortedSet<E>
inclusive - if true, the key will be included in the result, otherwise it will be excluded

to

@NotNull
public SortedSet<E> to(@NotNull
                               E value,
                               boolean inclusive)
Description copied from interface: SortedSet
Returns the top of the set up until the key specified.

Specified by:
to in interface SortedSet<E>
Overrides:
to in class AbstractSortedSet<E>
inclusive - if true, the key will be included in the result, otherwise it will be excluded

range

@NotNull
public 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 the from and to keys specified.

fromInclusive - if true, the key will be included in the result, otherwise it will be excluded
toInclusive - if true, the key will be included in the result, otherwise it will be excluded


Copyright © 2014. All Rights Reserved.