Java中的ConcurrentSkipListSet
ConcurrentSkipListSet具有默认情况下排序的元素。同样,其实现基于ConcurrentSkipListMap。ConcurrentSkipListSet类还实现了Collection接口以及AbstractSet类。它是JavaCollectionFramework的一部分。
演示此的程序如下所示-
示例
import java.util.concurrent.ConcurrentSkipListSet;
public class Demo {
public static void main(String[] args) {
ConcurrentSkipListSet<Integer> csls = new ConcurrentSkipListSet<Integer>();
csls.add(7);
csls.add(4);
csls.add(1);
csls.add(9);
csls.add(3);
System.out.println("The elements in ConcurrentSkipListSet are: " + csls);
}
}上面程序的输出如下-
输出结果
The elements in ConcurrentSkipListSet are: [1, 3, 4, 7, 9]
现在让我们了解上面的程序。
创建ConcurrentSkipListSet,然后将元素添加到其中。然后显示元素,并且默认情况下对这些元素进行排序。证明这一点的代码片段如下-
ConcurrentSkipListSet<Integer> csls = new ConcurrentSkipListSet<Integer>();
csls.add(7);
csls.add(4);
csls.add(1);
csls.add(9);
csls.add(3);
System.out.println("The elements in ConcurrentSkipListSet are: " + csls);热门推荐
10 英文祝福语简短带名字
11 送笔筒的祝福语简短
12 写给老师祝福语简短大学
13 结婚祝福语简短精辟好记
14 朋友花篮开业祝福语简短
15 女生 节日祝福语简短大气
16 春节感恩祝福语简短的
17 女生成年祝福语简短
18 生日祝福语 简短独特高考