forked from leavesCZY/AndroidGuide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedHashSet.java
More file actions
37 lines (29 loc) · 1018 Bytes
/
LinkedHashSet.java
File metadata and controls
37 lines (29 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package java.util;
public class LinkedHashSet<E>
extends HashSet<E>
implements Set<E>, Cloneable, java.io.Serializable {
//序列化ID
private static final long serialVersionUID = -2851667679971038690L;
//自定义初始容量与装载因子
public LinkedHashSet(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor, true);
}
//自定义初始容量
public LinkedHashSet(int initialCapacity) {
super(initialCapacity, .75f, true);
}
//使用默认的初始容量以及装载因子
public LinkedHashSet() {
super(16, .75f, true);
}
//使用初始数据、默认的初始容量以及装载因子
public LinkedHashSet(Collection<? extends E> c) {
super(Math.max(2*c.size(), 11), .75f, true);
addAll(c);
}
//并行遍历迭代器
@Override
public Spliterator<E> spliterator() {
return Spliterators.spliterator(this, Spliterator.DISTINCT | Spliterator.ORDERED);
}
}