Infolinks In Text Ads

Nov 22, 2010

SortedSet Interface

SortedSet Interface -
    After making the Set interface, There was a need to make an interface which can hold the elements in natural ordering. And give some extra facilities except to set interface. Then SortedSet was wrote.
    SortedSet Interface extends the Set Interface, maintain the sorting in ascending order. SortedSet is generic interface.

And Sorted Interface has some extra methods.

Comparator  comparator() -
This method gives the object of Comparator interface, If any comparator is used for implementing this SortedSet. If SortedSet has natural order then returns null.

Object first() -
This method is used to return the first (lowest) element from the current set.

Object last() -
This method is used to return the last (highest) element from the current set.

SortedSet subSet(Object start, Object end) -
    This method is used to return the SortedSet, include elements those belongs between start and end-1 elements.

SortedSet headSet(object end) -
This method is used for return the SortedSet with elements those are less then end element.

SortedSet tailSet(Object start) -
This method is used for return the SortedSet with elements those are greater than or equals to start element.

These are classes which implements SortedSet interface

   1. ConcurrentSkipListSet
   2. TreeSet

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...