java.util.TreeSet
A NavigableSet implementation based on a TreeMap.The elements are ordered using their natural ordering, or by a Comparator provided at a set creation time, depending on which constructor is used.
Some methods of TreeSet class.
add(String): This method adds the specified element to this set if it is not already present.
addAll(Collection): This method adds all of the elements in the specified collection to this set.
ceiling(String): This method returns the least element in this set greater than or equal to the given element, or null if there is no such element.
clear(): This method removes all of the elements from this set.
clone(): This method returns a shallow copy of this TreeSet instance.
comparator(): This method returns the comparator used to order the elements in this set,or null if this set uses the natural ordering of its elements.
contains(Object): This method returns true if this set contains the specified element.
descendingIterator(): This method returns an iterator over the elements in this set in descending order.
descendingSet(): This method returns a reverse order view of the elements contained in this set.
first(): This method returns the first (lowest) element currently in this set.
floor(String): This method returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
forEach(Consumer): This method performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
headSet(K): This method returns a view of the portion of this set whose elements are strictly less than toElement.
headSet(K, boolean): This method returns a view of the portion of this set whose elements are less than(or equal to, if inclusive is true) toElement.
Some more methods of TreeSet class
No comments:
Post a Comment