17 |
|
public class RWMap implements Map { |
18 |
|
private final Map m; |
19 |
|
private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); |
20 |
< |
|
20 |
> |
|
21 |
|
public RWMap(Map m) { |
22 |
|
if (m == null) |
23 |
|
throw new NullPointerException(); |
24 |
|
this.m = m; |
25 |
|
} |
26 |
|
|
27 |
< |
public RWMap() { |
27 |
> |
public RWMap() { |
28 |
|
this(new TreeMap()); // use TreeMap by default |
29 |
< |
// this(new IdentityHashMap()); |
29 |
> |
// this(new IdentityHashMap()); |
30 |
|
} |
31 |
|
|
32 |
|
public int size() { |
56 |
|
public Set keySet() { // Not implemented |
57 |
|
return m.keySet(); |
58 |
|
} |
59 |
< |
|
59 |
> |
|
60 |
|
public Set entrySet() { // Not implemented |
61 |
|
return m.entrySet(); |
62 |
|
} |
63 |
< |
|
63 |
> |
|
64 |
|
public Collection values() { // Not implemented |
65 |
|
return m.values(); |
66 |
|
} |
67 |
< |
|
67 |
> |
|
68 |
|
public boolean equals(Object o) { |
69 |
|
ReentrantReadWriteLock.ReadLock l = rwl.readLock(); |
70 |
|
l.lock(); try {return m.equals(o);} finally { l.unlock(); } |
96 |
|
ReentrantReadWriteLock.WriteLock l = rwl.writeLock(); |
97 |
|
l.lock(); try {m.clear();} finally { l.unlock(); } |
98 |
|
} |
99 |
< |
|
99 |
> |
|
100 |
|
} |