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