Build 1.0_r1(from source)

java.util
Interface SortedSet<E>

All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>
All Known Implementing Classes:
Collections.SynchronizedSortedSet, TreeSet

public interface SortedSet<E>
extends Set<E>

SortedSet is a Set which iterates its elements in sorted order.


Method Summary
 Comparator<? super E> comparator()
          Returns the Comparator used to compare elements in this SortedSet.
 E first()
          Answer the first sorted element in this SortedSet.
 SortedSet<E> headSet(E end)
          Returns a SortedSet of the specified portion of this SortedSet which contains elements less than the end element.
 E last()
          Answer the last sorted element in this SortedSet.
 SortedSet<E> subSet(E start, E end)
          Returns a SortedSet of the specified portion of this SortedSet which contains elements greater or equal to the start element but less than the end element.
 SortedSet<E> tailSet(E start)
          Returns a SortedSet of the specified portion of this SortedSet which contains elements greater or equal to the start element.
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

comparator

Comparator<? super E> comparator()
Returns the Comparator used to compare elements in this SortedSet.

Returns:
a Comparator or null if the natural order is used

first

E first()
Answer the first sorted element in this SortedSet.

Returns:
the first sorted element
Throws:
NoSuchElementException - when this SortedSet is empty

headSet

SortedSet<E> headSet(E end)
Returns a SortedSet of the specified portion of this SortedSet which contains elements less than the end element. The returned SortedSet is backed by this SortedSet so changes to one are reflected by the other.

Parameters:
end - the end element
Returns:
a subset where the elements are less than end
Throws:
ClassCastException - when the class of the end element is inappropriate for this SubSet
NullPointerException - when the end element is null and this SortedSet does not support null elements

last

E last()
Answer the last sorted element in this SortedSet.

Returns:
the last sorted element
Throws:
NoSuchElementException - when this SortedSet is empty

subSet

SortedSet<E> subSet(E start,
                    E end)
Returns a SortedSet of the specified portion of this SortedSet which contains elements greater or equal to the start element but less than the end element. The returned SortedSet is backed by this SortedMap so changes to one are reflected by the other.

Parameters:
start - the start element
end - the end element
Returns:
a subset where the elements are greater or equal to start and less than end
Throws:
ClassCastException - when the class of the start or end element is inappropriate for this SubSet
NullPointerException - when the start or end element is null and this SortedSet does not support null elements
IllegalArgumentException - when the start element is greater than the end element

tailSet

SortedSet<E> tailSet(E start)
Returns a SortedSet of the specified portion of this SortedSet which contains elements greater or equal to the start element. The returned SortedSet is backed by this SortedSet so changes to one are reflected by the other.

Parameters:
start - the start element
Returns:
a subset where the elements are greater or equal to start
Throws:
ClassCastException - when the class of the start element is inappropriate for this SubSet
NullPointerException - when the start element is null and this SortedSet does not support null elements

Build 1.0_r1(from source)

Please submit a feedback, bug or feature