run ooojava and rcrpointer that print out effects and annotate them with the source...
[IRC.git] / Robust / src / Analysis / Pointer / MySet.java
1 package Analysis.Pointer;
2 import java.util.*;
3
4 public class MySet<T> extends AbstractSet<T> {
5   HashMap<T,T> map;
6   boolean locked;
7   public MySet(boolean locked) {
8     this.locked=locked;
9     map=new HashMap<T,T>();
10   }
11
12   public MySet() {
13     map=new HashMap<T,T>();
14   }
15
16   public MySet(T obj) {
17     map=new HashMap<T,T>();
18     add(obj);
19   }
20
21   public MySet(MySet base) {
22     map=new HashMap<T,T>();
23     if (base!=null)
24       addAll(base);
25   }
26
27   public int size() {
28     return map.size();
29   }
30
31   public void clear() {
32     map.clear();
33   }
34
35   public boolean remove(Object obj) {
36     if (locked)
37       throw new Error();
38     return map.remove(obj)!=null;
39   }
40
41   public boolean add(T obj) {
42     if (locked)
43       throw new Error();
44     boolean retval=map.remove(obj)==null;
45     map.put(obj, obj);
46     return retval;
47   }
48
49   public boolean contains(Object obj) {
50     return map.containsKey(obj);
51   }
52
53   public boolean removeAll(Collection c) {
54     if (c!=null)
55       return super.removeAll(c);
56     else
57       return false;
58   }
59
60   public boolean addAll(Collection c) {
61     if (c!=null)
62       return super.addAll(c);
63     else
64       return false;
65   }
66
67   public T get(T obj) {
68     return map.get(obj);
69   }
70
71   public boolean isEmpty() {
72     return map.isEmpty();
73   }
74
75   public Iterator<T> iterator() {
76     return map.keySet().iterator();
77   }
78
79   public Object clone() {
80     MySet<T> cl=new MySet<T>();
81     cl.map.putAll(this.map);
82     return cl;
83   }
84 }