java.util.concurrent.ConcurrentSkipListSet的descendingIterator()方法是Java中的內置函數,用於按降序返回此集合中元素的迭代器。
用法:
ConcurrentSkipListSet.descendingIterator()
返回值:函數以降序返回此集合中元素的迭代器。
以下示例程序旨在說明ConcurrentSkipListSet.descendingIterator()方法:
程序1:
// Java Program Demonstrate descendingIterator()
// method of ConcurrentSkipListSet
import java.util.Iterator;
import java.util.concurrent.ConcurrentSkipListSet;
class ConcurrentSkipListSetIteratorExample1 {
public static void main(String[] args)
{
// Initializing the set
ConcurrentSkipListSet<String>
set = new ConcurrentSkipListSet<String>();
// Adding elements to this set
set.add("Gfg");
set.add("is");
set.add("fun!!");
// Returns an iterator over the elements
Iterator<String> iterator = set.descendingIterator();
// Printing the elements of the set
while (iterator.hasNext())
System.out.print(iterator.next() + " ");
}
}
輸出:
is fun!! Gfg
程序2:
// Java Program Demonstrate descendingIterator()
// method of ConcurrentSkipListSet
import java.util.Iterator;
import java.util.concurrent.ConcurrentSkipListSet;
class ConcurrentSkipListSetIteratorExample1 {
public static void main(String[] args)
{
// Initializing the set
ConcurrentSkipListSet<Integer>
set = new ConcurrentSkipListSet<Integer>();
// Adding elements to this set
set.add(10);
set.add(15);
set.add(20);
set.add(25);
// Returns an iterator over the elements
Iterator<Integer> iterator = set.descendingIterator();
// Printing the elements of the set
while (iterator.hasNext())
System.out.print(iterator.next() + " ");
}
}
輸出:
25 20 15 10
相關用法
- Java ConcurrentLinkedDeque descendingIterator()用法及代碼示例
- Java LinkedBlockingDeque descendingIterator()用法及代碼示例
- Java NavigableSet descendingIterator()用法及代碼示例
- Java Deque descendingIterator()用法及代碼示例
- Java ArrayDeque descendingIterator()用法及代碼示例
- Java LinkedList descendingIterator()用法及代碼示例
- Java TreeSet descendingIterator()用法及代碼示例
- Java ConcurrentSkipListSet last()用法及代碼示例
- Java ConcurrentSkipListSet add()用法及代碼示例
- Java ConcurrentSkipListSet first()用法及代碼示例
- Java ConcurrentSkipListSet contains()用法及代碼示例
- Java ConcurrentSkipListSet floor()用法及代碼示例
- Java ConcurrentSkipListSet descendingSet()用法及代碼示例
- Java ConcurrentSkipListSet headSet()用法及代碼示例
- Java ConcurrentSkipListSet isEmpty()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 ConcurrentSkipListSet descendingIterator() method in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。