org.compass.core.util.backport.java.util
Class TreeSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by org.compass.core.util.backport.java.util.TreeSet
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, Set, SortedSet, NavigableSet

public class TreeSet
extends AbstractSet
implements NavigableSet, Cloneable, Serializable

See Also:
Serialized Form

Nested Class Summary
(package private) static class TreeSet.IOIterator
           
 
Constructor Summary
TreeSet()
           
TreeSet(Collection c)
           
TreeSet(Comparator comparator)
           
TreeSet(SortedSet s)
           
 
Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 Object ceiling(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()
           
 Object clone()
           
 Comparator comparator()
           
 boolean contains(Object o)
           
 Iterator descendingIterator()
          Returns an iterator over the elements in this set, in descending order.
 Object first()
           
 Object floor(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.
 SortedSet headSet(Object toElement)
           
 Object higher(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()
           
 Iterator iterator()
          Returns an iterator over the elements in this set, in ascending order.
 Object last()
           
 Object lower(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(Object toElement)
          Returns a view of the portion of this set whose elements are strictly less than toElement.
 NavigableSet navigableSubSet(Object fromElement, Object toElement)
          Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
 NavigableSet navigableTailSet(Object fromElement)
          Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
 Object pollFirst()
          Retrieves and removes the first (lowest) element, or returns null if this set is empty.
 Object pollLast()
          Retrieves and removes the last (highest) element, or returns null if this set is empty.
 boolean remove(Object o)
           
 int size()
           
 SortedSet subSet(Object fromElement, Object toElement)
           
 SortedSet tailSet(Object fromElement)
           
 Object[] toArray()
           
 Object[] toArray(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(Comparator comparator)

TreeSet

public TreeSet(Collection c)

TreeSet

public TreeSet(SortedSet s)
Method Detail

lower

public Object lower(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 Object floor(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 Object ceiling(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 Object higher(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 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 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 Iterator iterator()
Description copied from interface: NavigableSet
Returns an iterator over the elements in this set, in ascending order.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in interface NavigableSet
Specified by:
iterator in class AbstractCollection
Returns:
an iterator over the elements in this set, in ascending order

descendingIterator

public 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(Object fromElement,
                                    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(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(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 Comparator comparator()
Specified by:
comparator in interface SortedSet

subSet

public SortedSet subSet(Object fromElement,
                        Object toElement)
Specified by:
subSet in interface SortedSet

headSet

public SortedSet headSet(Object toElement)
Specified by:
headSet in interface SortedSet

tailSet

public SortedSet tailSet(Object fromElement)
Specified by:
tailSet in interface SortedSet

first

public Object first()
Specified by:
first in interface SortedSet

last

public Object last()
Specified by:
last in interface SortedSet

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set
Overrides:
isEmpty in class AbstractCollection

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection
Specified by:
contains in interface Set
Overrides:
contains in class AbstractCollection

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
Overrides:
toArray in class AbstractCollection

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
Overrides:
toArray in class AbstractCollection

add

public boolean add(Object o)
Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface Set
Overrides:
addAll in class AbstractCollection

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface Set
Overrides:
clear in class AbstractCollection

clone

public Object clone()
Overrides:
clone in class Object


Copyright (c) 2004-2006 The Compass Project.