ConcurrentSkipListSet descendingSet() method in Java
The descendingSet() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns a reverse order view of the elements contained in this set. The descending set is backed by this set, so changes to the set are reflected in the descending set, and vice-versa.
Return Value: The function returns a NavigableSet which is a reverse order view of this set.
Below programs illustrate the ConcurrentSkipListSet.Set() method:
Contents of the set: [10, 20, 25, 35] Contents of the descending set: [35, 25, 20, 10]
Program 2: Program demonstrating change in the original set while insertion of elements in the descending set.
Contents of the set: [alex, bob, chuck, drake, eric, fred] Contents of the descending set: [fred, eric, drake, chuck, bob, alex]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.