ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/SMap.java
Revision: 1.6
Committed: Sun Oct 21 06:40:21 2012 UTC (11 years, 6 months ago) by jsr166
Branch: MAIN
Changes since 1.5: +0 -2 lines
Log Message:
no blank line between javadoc and corresponding code

File Contents

# Content
1 /*
2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 * Expert Group and released to the public domain, as explained at
4 * http://creativecommons.org/publicdomain/zero/1.0/
5 */
6 import java.util.*;
7 import java.util.concurrent.*;
8 import java.util.concurrent.locks.*;
9
10 /**
11 * This is an incomplete implementation of a wrapper class
12 * that places read-write locks around unsynchronized Maps.
13 * Exists as a sample input for MapLoops test.
14 */
15 public class SMap implements Map {
16 private final Map m;
17 public SMap(Map m) {
18 if (m == null)
19 throw new NullPointerException();
20 this.m = m;
21 }
22
23 public SMap() {
24 this(new TreeMap()); // use TreeMap by default
25 }
26
27 public synchronized int size() {
28 return m.size();
29 }
30 public synchronized boolean isEmpty() {
31 return m.isEmpty();
32 }
33
34 public synchronized Object get(Object key) {
35 return m.get(key);
36 }
37
38 public synchronized boolean containsKey(Object key) {
39 return m.containsKey(key);
40 }
41 public synchronized boolean containsValue(Object value) {
42 return m.containsValue(value);
43 }
44
45
46 public synchronized Set keySet() { // Not implemented
47 return m.keySet();
48 }
49
50 public synchronized Set entrySet() { // Not implemented
51 return m.entrySet();
52 }
53
54 public synchronized Collection values() { // Not implemented
55 return m.values();
56 }
57
58 public synchronized boolean equals(Object o) {
59 return m.equals(o);
60 }
61 public synchronized int hashCode() {
62 return m.hashCode();
63 }
64 public synchronized String toString() {
65 return m.toString();
66 }
67
68
69
70 public synchronized Object put(Object key, Object value) {
71 return m.put(key, value);
72 }
73 public synchronized Object remove(Object key) {
74 return m.remove(key);
75 }
76 public synchronized void putAll(Map map) {
77 m.putAll(map);
78 }
79 public synchronized void clear() {
80 m.clear();
81 }
82
83 }