Sunday, 16 October 2016

What is NavigableSet Interface In Java ?

Previously we have discussed about
Here we learn What is NavigableSet interface in Java.But Before That you must Know What is Collection Interface in Java ?
Interface NavigableSet<E>

Type Parameters:
E - the type of elements maintained by this set

All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>, SortedSet<E>

All Known Implementing Classes:
ConcurrentSkipListSet, TreeSet

Declaration of NavigableSet:
public interface NavigableSet<E>
extends SortedSet<E>

NavigableSet extends SortedSet and declares the behavior of a collection that supports the retrieval of elements based on the closest match to a given value.

A NavigableSet may be accessed and traversed in either ascending or descending order. The performance of ascending operations and views is likely to be faster than that of descending ones. Methods lower, floor, ceiling, and higher return elements respectively less than, less than or equal, greater than or equal, and greater than a given element, returning null if there is no such element.

This interface additionally defines methods pollFirst and pollLast that return and remove the lowest and highest element, if one exists, else returning null. Subsets of any NavigableSet must implement the NavigableSet interface.
This interface is a member of the Java Collections Framework.

Method Summary of NavigableSet:

Modifier and Method Name
Description
E ceiling(E e)
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
Iterator<E> descendingIterator()
Returns an iterator over the elements in this set, in descending order.
NavigableSet<E> descendingSet()
Returns a reverse order view of the elements contained in this set.
E floor(E 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<E> headSet(E toElement)
Returns a view of the portion of this set whose elements are strictly less than toElement.
NavigableSet<E> headSet(E toElement, boolean inclusive)
Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement.
E higher(E e)
Returns the least element in this set strictly greater than the given element, or null if there is no such element.
Iterator<E> iterator()
Returns an iterator over the elements in this set, in ascending order.
E lower(E e)
Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
E pollFirst()
Retrieves and removes the first (lowest) element, or returns null if this set is empty.
E pollLast()
Retrieves and removes the last (highest) element, or returns null if this set is empty.
NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Returns a view of the portion of this set whose elements range from fromElement to toElement.
SortedSet<E> subSet(E fromElement, E toElement)
Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
SortedSet<E> tailSet(E fromElement)
Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
NavigableSet<E> tailSet(E fromElement, boolean inclusive)
Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement.
      

Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



No comments:

Post a Comment