OrderedSet.java
2.27 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Decompiled with CFR 0_118.
*/
package com.day.util;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
public class OrderedSet
implements Set {
private final HashSet set;
private final LinkedList list = new LinkedList();
public OrderedSet() {
this.set = new HashSet();
}
public OrderedSet(Collection c) {
this.set = new HashSet(Math.max((int)((float)c.size() / 0.75f) + 1, 16));
this.addAll(c);
}
public OrderedSet(int initialCapacity, float loadFactor) {
this.set = new HashSet(initialCapacity, loadFactor);
}
public OrderedSet(int initialCapacity) {
this.set = new HashSet(initialCapacity);
}
public int size() {
return this.set.size();
}
public boolean isEmpty() {
return this.set.isEmpty();
}
public boolean contains(Object o) {
return this.set.contains(o);
}
public Iterator iterator() {
return this.list.iterator();
}
public Object[] toArray() {
return this.list.toArray();
}
public Object[] toArray(Object[] a) {
return this.list.toArray(a);
}
public boolean add(Object o) {
if (this.set.add(o)) {
this.list.add(o);
return true;
}
return false;
}
public boolean remove(Object o) {
if (this.set.remove(o)) {
this.list.remove(o);
return true;
}
return false;
}
public boolean containsAll(Collection c) {
return this.set.containsAll(c);
}
public boolean addAll(Collection c) {
boolean ret = false;
Iterator iter = c.iterator();
while (iter.hasNext()) {
ret |= this.add(iter.next());
}
return ret;
}
public boolean retainAll(Collection c) {
this.set.clear();
this.list.clear();
return this.addAll(c);
}
public boolean removeAll(Collection c) {
boolean ret = false;
Iterator iter = c.iterator();
while (iter.hasNext()) {
ret |= this.remove(iter.next());
}
return ret;
}
public void clear() {
this.set.clear();
this.list.clear();
}
}