edu.emory.mathcs.backport.java.util
Class TreeSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byedu.emory.mathcs.backport.java.util.TreeSet
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, NavigableSet, java.io.Serializable, java.util.Set, java.util.SortedSet

public class TreeSet
extends java.util.AbstractSet
implements NavigableSet, java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form

Constructor Summary
TreeSet()
           
TreeSet(java.util.Collection c)
           
TreeSet(java.util.Comparator comparator)
           
TreeSet(java.util.SortedSet s)
           
 
Method Summary
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 java.lang.Object ceiling(java.lang.Object e)
          Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
 void clear()
           
 java.lang.Object clone()
           
 java.util.Comparator comparator()
           
 boolean contains(java.lang.Object o)
           
 java.util.Iterator descendingIterator()
          Returns an iterator over the elements in this set, in descending order.
 java.lang.Object first()
           
 java.lang.Object floor(java.lang.Object e)
          Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
 java.util.SortedSet headSet(java.lang.Object toElement)
           
 java.lang.Object higher(java.lang.Object e)
          Returns the least element in this set strictly greater than the given element, or null if there is no such element.
 boolean isEmpty()
           
 java.util.Iterator iterator()
          Returns an iterator over the elements in this set, in ascending order.
 java.lang.Object last()
           
 java.lang.Object lower(java.lang.Object e)
          Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
 NavigableSet navigableHeadSet(java.lang.Object toElement)
          Returns a view of the portion of this set whose elements are strictly less than toElement.
 NavigableSet navigableSubSet(java.lang.Object fromElement, java.lang.Object toElement)
          Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
 NavigableSet navigableTailSet(java.lang.Object fromElement)
          Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
 java.lang.Object pollFirst()
          Retrieves and removes the first (lowest) element, or returns null if this set is empty.
 java.lang.Object pollLast()
          Retrieves and removes the last (highest) element, or returns null if this set is empty.
 boolean remove(java.lang.Object o)
           
 int size()
           
 java.util.SortedSet subSet(java.lang.Object fromElement, java.lang.Object toElement)
           
 java.util.SortedSet tailSet(java.lang.Object fromElement)
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll
 

Constructor Detail

TreeSet

public TreeSet()

TreeSet

public TreeSet(java.util.Comparator comparator)

TreeSet

public TreeSet(java.util.Collection c)

TreeSet

public TreeSet(java.util.SortedSet s)
Method Detail

lower

public java.lang.Object lower(java.lang.Object e)
Description copied from interface: NavigableSet
Returns the greatest element in this set strictly less than the given element, or null if there is no such element.

Specified by:
lower in interface NavigableSet
Parameters:
e - the value to match
Returns:
the greatest element less than e, or null if there is no such element

floor

public java.lang.Object floor(java.lang.Object e)
Description copied from interface: NavigableSet
Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.

Specified by:
floor in interface NavigableSet
Parameters:
e - the value to match
Returns:
the greatest element less than or equal to e, or null if there is no such element

ceiling

public java.lang.Object ceiling(java.lang.Object e)
Description copied from interface: NavigableSet
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.

Specified by:
ceiling in interface NavigableSet
Parameters:
e - the value to match
Returns:
the least element greater than or equal to e, or null if there is no such element

higher

public java.lang.Object higher(java.lang.Object e)
Description copied from interface: NavigableSet
Returns the least element in this set strictly greater than the given element, or null if there is no such element.

Specified by:
higher in interface NavigableSet
Parameters:
e - the value to match
Returns:
the least element greater than e, or null if there is no such element

pollFirst

public java.lang.Object pollFirst()
Description copied from interface: NavigableSet
Retrieves and removes the first (lowest) element, or returns null if this set is empty.

Specified by:
pollFirst in interface NavigableSet
Returns:
the first element, or null if this set is empty

pollLast

public java.lang.Object pollLast()
Description copied from interface: NavigableSet
Retrieves and removes the last (highest) element, or returns null if this set is empty.

Specified by:
pollLast in interface NavigableSet
Returns:
the last element, or null if this set is empty

iterator

public java.util.Iterator iterator()
Description copied from interface: NavigableSet
Returns an iterator over the elements in this set, in ascending order.

Specified by:
iterator in interface NavigableSet

descendingIterator

public java.util.Iterator descendingIterator()
Description copied from interface: NavigableSet
Returns an iterator over the elements in this set, in descending order.

Specified by:
descendingIterator in interface NavigableSet
Returns:
an iterator over the elements in this set, in descending order

navigableSubSet

public NavigableSet navigableSubSet(java.lang.Object fromElement,
                                    java.lang.Object toElement)
Description copied from interface: NavigableSet
Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Specified by:
navigableSubSet in interface NavigableSet
Parameters:
fromElement - low endpoint (inclusive) of the returned set
toElement - high endpoint (exclusive) of the returned set
Returns:
a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

navigableHeadSet

public NavigableSet navigableHeadSet(java.lang.Object toElement)
Description copied from interface: NavigableSet
Returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Specified by:
navigableHeadSet in interface NavigableSet
Parameters:
toElement - high endpoint (exclusive) of the returned set
Returns:
a view of the portion of this set whose elements are strictly less than toElement

navigableTailSet

public NavigableSet navigableTailSet(java.lang.Object fromElement)
Description copied from interface: NavigableSet
Returns a view of the portion of this set whose elements are greater than or equal to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Specified by:
navigableTailSet in interface NavigableSet
Parameters:
fromElement - low endpoint (inclusive) of the returned set
Returns:
a view of the portion of this set whose elements are greater than or equal to fromElement

comparator

public java.util.Comparator comparator()
Specified by:
comparator in interface java.util.SortedSet

subSet

public java.util.SortedSet subSet(java.lang.Object fromElement,
                                  java.lang.Object toElement)
Specified by:
subSet in interface java.util.SortedSet

headSet

public java.util.SortedSet headSet(java.lang.Object toElement)
Specified by:
headSet in interface java.util.SortedSet

tailSet

public java.util.SortedSet tailSet(java.lang.Object fromElement)
Specified by:
tailSet in interface java.util.SortedSet

first

public java.lang.Object first()
Specified by:
first in interface java.util.SortedSet

last

public java.lang.Object last()
Specified by:
last in interface java.util.SortedSet

size

public int size()
Specified by:
size in interface java.util.Set

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Set

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.Set

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Set

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Set

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Set

clear

public void clear()
Specified by:
clear in interface java.util.Set

clone

public java.lang.Object clone()