| java.lang.Object | |||
| ↳ | java.util.AbstractCollection<E> | ||
| ↳ | java.util.AbstractSet<E> | ||
| ↳ | java.util.TreeSet<E> | ||
TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are supported. The elements can be any objects which are comparable to each other either using their natural order or a specified Comparator.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new empty instance of  
  
  TreeSet which uses natural
 ordering. | |||||||||||
Constructs a new instance of  
  
  TreeSet which uses natural ordering
 and containing the unique elements in the specified collection. | |||||||||||
Constructs a new empty instance of  
  
  TreeSet which uses the
 specified comparator. | |||||||||||
Constructs a new instance of  
  
  TreeSet containing the elements of
 the specified SortedSet and using the same Comparator. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified object to this  
  
  TreeSet. | |||||||||||
Adds the objects in the specified collection to this  
  
  TreeSet. | |||||||||||
Returns the smallest element bigger than or equal to the specified one,
 or null if no such element. 
  
   | |||||||||||
Removes all elements from this  
  
  TreeSet, leaving it empty. | |||||||||||
Returns a new  
  
  TreeSet with the same elements, size and comparator
 as this TreeSet. | |||||||||||
Returns the comparator used to compare elements in this  
  
  TreeSet. | |||||||||||
Searches this  
  
  TreeSet for the specified object. | |||||||||||
Returns a descending iterator of this set. 
  
   | |||||||||||
Returns a reverse order view of this set. 
  
   | |||||||||||
Returns the first element in this set. 
  
   | |||||||||||
Returns the biggest element less than or equal to the specified one, or
 null if no such element. 
  
   | |||||||||||
Returns a  
  
  SortedSet of the specified portion of this TreeSet which
 contains elements less than the end element. | |||||||||||
Returns a NavigableSet of the specified portion of this set which
 contains elements less than (or equal to, depends on endInclusive) the
 end element. 
  
   | |||||||||||
Returns the smallest element bigger than the specified one, or null if no
 such element. 
  
   | |||||||||||
Returns true if this  
  
  TreeSet has no element, otherwise false. | |||||||||||
Returns an Iterator on the elements of this  
  
  TreeSet. | |||||||||||
Returns the last element in this set. 
  
   | |||||||||||
Returns the biggest element less than the specified one, or null if no
 such element. 
  
   | |||||||||||
Deletes and returns the smallest element, or null if the set is empty. 
  
   | |||||||||||
Deletes and returns the biggest element, or null if the set is empty. 
  
   | |||||||||||
Removes an occurrence of the specified object from this  
  
  TreeSet. | |||||||||||
Returns the number of elements in this  
  
  TreeSet. | |||||||||||
Returns a  
  
  SortedSet of the specified portion of this TreeSet which
 contains elements greater or equal to the start element but less than the
 end element. | |||||||||||
Returns a NavigableSet of the specified portion of this set which
 contains elements greater (or equal to, depends on startInclusive) the
 start element but less than (or equal to, depends on endInclusive) the
 end element. 
  
   | |||||||||||
Returns a NavigableSet of the specified portion of this set which
 contains elements greater (or equal to, depends on startInclusive) the
 start element. 
  
   | |||||||||||
Returns a  
  
  SortedSet of the specified portion of this TreeSet which
 contains elements greater or equal to the start element. | |||||||||||
| 
  [Expand]
   Inherited Methods  | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
   
From class java.util.AbstractSet
 | |||||||||||
   
From class java.util.AbstractCollection
 | |||||||||||
   
From class java.lang.Object
 | |||||||||||
   
From interface java.lang.Iterable
 | |||||||||||
   
From interface java.util.Collection
 | |||||||||||
   
From interface java.util.NavigableSet
 | |||||||||||
   
From interface java.util.Set
 | |||||||||||
   
From interface java.util.SortedSet
 | |||||||||||
Constructs a new empty instance of TreeSet which uses natural
 ordering.
Constructs a new instance of TreeSet which uses natural ordering
 and containing the unique elements in the specified collection.
| collection | the collection of elements to add. | 
|---|
| ClassCastException | when an element in the collection does not implement the Comparable interface, or the elements in the collection cannot be compared. | 
|---|
Constructs a new empty instance of TreeSet which uses the
 specified comparator.
| comparator | the comparator to use. | 
|---|
Constructs a new instance of TreeSet containing the elements of
 the specified SortedSet and using the same Comparator.
| set | the SortedSet of elements to add. | 
|---|
Adds the specified object to this TreeSet.
| object | the object to add. | 
|---|
true when this TreeSet did not already contain
         the object, false otherwise.| ClassCastException | when the object cannot be compared with the elements in this
             TreeSet. | 
        
|---|---|
| NullPointerException | when the object is null and the comparator cannot handle null. | 
Adds the objects in the specified collection to this TreeSet.
| collection | the collection of objects to add. | 
|---|
true if this TreeSet was modified, false
         otherwise.| ClassCastException | when an object in the collection cannot be compared with the
             elements in this TreeSet. | 
        
|---|---|
| NullPointerException | when an object in the collection is null and the comparator cannot handle null. | 
Returns the smallest element bigger than or equal to the specified one, or null if no such element.
| e | the specified element | 
|---|
Returns a new TreeSet with the same elements, size and comparator
 as this TreeSet.
TreeSet.Returns the comparator used to compare elements in this TreeSet.
Searches this TreeSet for the specified object.
| object | the object to search for. | 
|---|
true if object is an element of this
         TreeSet, false otherwise.| ClassCastException | when the object cannot be compared with the elements in this
             TreeSet. | 
        
|---|---|
| NullPointerException | when the object is null and the comparator cannot handle null. | 
Returns a descending iterator of this set.
Returns the first element in this set.
| NoSuchElementException | when this TreeSet is empty | 
|---|
Returns the biggest element less than or equal to the specified one, or null if no such element.
| e | the specified element | 
|---|
Returns a SortedSet of the specified portion of this TreeSet which
 contains elements less than the end element. The returned SortedSet is
 backed by this TreeSet so changes to one are reflected by the other.
| end | the end element | 
|---|
end| ClassCastException | when the end object cannot be compared with the elements in this TreeSet | 
|---|---|
| NullPointerException | when the end object is null and the comparator cannot handle null | 
Returns a NavigableSet of the specified portion of this set which contains elements less than (or equal to, depends on endInclusive) the end element. The returned NavigableSet is backed by this set so changes to one are reflected by the other.
| end | the end element | 
|---|---|
| endInclusive | true if the end element is in the returned set | 
Returns the smallest element bigger than the specified one, or null if no such element.
| e | the specified element | 
|---|
Returns true if this TreeSet has no element, otherwise false.
TreeSet has no element.Returns an Iterator on the elements of this TreeSet.
TreeSet.Returns the last element in this set.
| NoSuchElementException | when this TreeSet is empty | 
|---|
Returns the biggest element less than the specified one, or null if no such element.
| e | the specified element | 
|---|
Deletes and returns the smallest element, or null if the set is empty.
Deletes and returns the biggest element, or null if the set is empty.
Removes an occurrence of the specified object from this TreeSet.
| object | the object to remove. | 
|---|
true if this TreeSet was modified, false
         otherwise.| ClassCastException | when the object cannot be compared with the elements in this
             TreeSet. | 
        
|---|---|
| NullPointerException | when the object is null and the comparator cannot handle null. | 
Returns the number of elements in this TreeSet.
TreeSet.
Returns a SortedSet of the specified portion of this TreeSet which
 contains elements greater or equal to the start element but less than the
 end element. The returned SortedSet is backed by this TreeSet so changes
 to one are reflected by the other.
| start | the start element | 
|---|---|
| end | the end element | 
start and less than end| ClassCastException | when the start or end object cannot be compared with the elements in this TreeSet | 
|---|---|
| NullPointerException | when the start or end object is null and the comparator cannot handle null | 
Returns a NavigableSet of the specified portion of this set which contains elements greater (or equal to, depends on startInclusive) the start element but less than (or equal to, depends on endInclusive) the end element. The returned NavigableSet is backed by this set so changes to one are reflected by the other.
| start | the start element | 
|---|---|
| startInclusive | true if the start element is in the returned set | 
| end | the end element | 
| endInclusive | true if the end element is in the returned set | 
Returns a NavigableSet of the specified portion of this set which contains elements greater (or equal to, depends on startInclusive) the start element. The returned NavigableSet is backed by this set so changes to one are reflected by the other.
| start | the start element | 
|---|---|
| startInclusive | true if the start element is in the returned set | 
Returns a SortedSet of the specified portion of this TreeSet which
 contains elements greater or equal to the start element. The returned
 SortedSet is backed by this TreeSet so changes to one are reflected by
 the other.
| start | the start element | 
|---|
start| ClassCastException | when the start object cannot be compared with the elements in this TreeSet | 
|---|---|
| NullPointerException | when the start object is null and the comparator cannot handle null |