This interface is the part of Java Collection Interface.
Important Point of SortedSet
- It provides ordering of Its element.
- Elements are ordered on the basis of Comparable / Comparator provided @ the time of creation of SortedSet.
- Iterator will traverse the set in ascending order.
- This interface is the set analogue of SortedMap.
- Elements inserted in SortedSet needs to implement Comparable Interface (Or accepting the comparator interface).
- All implementation of SortedSet should provide 4 constructor.
- No Arg Constructor
- Constructor with single argument of Comparator.
- Constructor with single argument as Collection.
- Constructor with single argument as SortedSet.
Important Method In SortedSet
- Comparator<? super E> comparator() : Returns the comparator used to order the elements in this Set.
- subSet(E fromElement, E toElement) : Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
- headSet(E toElement) : Returns a view of the portion of this set whose elements are strictly less than toElement.
- tailSet(E fromElement) : Returns a view of the portion of this set whose elements are greater than or equal to fromElement