SortedSet Interface
Home ] Up ] Set Interface ] HashSet Class ] [ SortedSet Interface ] TreeSet Class ] TreeSet with Comparator ]

 

 

If you want a set that is ordered, then you can use a SortedSet interface:

Collection
    Set
        SortedSet

The SortedSet interface adds the following methods to those already specified by Set:

Method Description
comparator() Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
subSet(fromElement, toElement) Returns a view of the portion of this sorted set whose elements range  from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned sorted set is empty.) 
headSet(toElement) Returns a view of the portion of this sorted set whose elements are strictly less than toElement.
tailSet(fromElement) Returns a view of the portion of this sorted set whose elements are greater than or equal to fromElement.
first() Returns the first (lowest) element currently in this sorted set.
last() Returns the last (highest) element currently in this sorted set.
 

This page was last modified on 02 October, 2007