1
2
3
4
5
6
7
8
9
10
11 package org.mule.util.concurrent;
12
13
14
15
16
17
18
19 import java.io.IOException;
20 import java.io.Serializable;
21 import java.util.AbstractSet;
22 import java.util.Collection;
23 import java.util.Iterator;
24 import java.util.Set;
25
26 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
27
28 public class ConcurrentHashSet
29 {
30 private static final long serialVersionUID = 2454657854757543876L;
31
32 private final ConcurrentHashMap
33 private transient Set
34
35 public ConcurrentHashSet()
36 {
37 map = new ConcurrentHashMap
38 keySet = map.keySet();
39 }
40
41 public ConcurrentHashSet(int initialCapacity)
42 {
43 map = new ConcurrentHashMap
44 keySet = map.keySet();
45 }
46
47 public ConcurrentHashSet(int initialCapacity, float loadFactor, int concurrencyLevel)
48 {
49 map = new ConcurrentHashMap
50 keySet = map.keySet();
51 }
52
53 public int size()
54 {
55 return map.size();
56 }
57
58 public boolean isEmpty()
59 {
60 return map.isEmpty();
61 }
62
63 public boolean contains(Object o)
64 {
65 return map.containsKey(o);
66 }
67
68 public Iterator
69 {
70 return keySet.iterator();
71 }
72
73 public Object[] toArray()
74 {
75 return keySet.toArray();
76 }
77
78 public
79 {
80 return keySet.toArray(a);
81 }
82
83 public boolean add(Object
84 {
85 return map.put(e, Boolean.TRUE) == null;
86 }
87
88 public boolean remove(Object o)
89 {
90 return map.remove(o) != null;
91 }
92
93 public boolean removeAll(Collection
94 {
95 return keySet.removeAll(c);
96 }
97
98 public boolean retainAll(Collection
99 {
100 return keySet.retainAll(c);
101 }
102
103 public void clear()
104 {
105 map.clear();
106 }
107
108 public boolean equals(Object o)
109 {
110 return keySet.equals(o);
111 }
112
113 public int hashCode()
114 {
115 return keySet.hashCode();
116 }
117
118 private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException
119 {
120 s.defaultReadObject();
121 keySet = map.keySet();
122 }
123
124 }