ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/SMap.java
Revision: 1.2
Committed: Mon May 9 19:33:30 2005 UTC (19 years ago) by dl
Branch: MAIN
Changes since 1.1: +5 -0 lines
Log Message:
Add headers

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