1 | class SetProxy implements java.util.Set {↵ | | 1 | class EntrySetProxy implements Set {↵
|
|
2 | final Collection set;↵ | | 2 | private final Set set;↵
|
|
3 | SetProxy(Collection set) {↵ | | 3 | EntrySetProxy(Set set) {↵
|
4 | this.set=set;↵ | | 4 | this.set=set;↵
|
5 | }↵ | | 5 | }↵
|
6 | public boolean add(Object o) {↵ | | 6 | public boolean add(Object entry) {↵
|
7 | write();↵ | | 7 | //write(); -- doesn't↵
|
8 | return set.add(o);↵ | | 8 | return set.add(entry);↵
|
9 | }↵ | | 9 | }↵
|
|
10 | public boolean addAll(Collection c) {↵ | | 10 | public boolean addAll(Collection entries) {↵
|
11 | write();↵ | | 11 | //write(); -- doesn't↵
|
12 | return set.addAll(c);↵ | | 12 | return set.addAll(entries);↵
|
13 | }↵ | | 13 | }↵
|
|
14 | public void clear() {↵ | | 14 | public void clear() {↵
|
15 | write();↵ | | 15 | write();↵
|
16 | set.clear();↵ | | 16 | set.clear();↵
|
17 | }↵ | | 17 | }↵
|
|
18 | public boolean contains(Object o) {↵ | | 18 | public boolean contains(Object entry) {↵
|
19 | return set.contains(o);↵ | | 19 | return set.contains(entry);↵
|
20 | }↵ | | 20 | }↵
|
|
21 | public boolean containsAll(Collection c) {↵ | | 21 | public boolean containsAll(Collection entries) {↵
|
22 | return set.containsAll(c);↵ | | 22 | return set.containsAll(entries);↵
|
23 | }↵ | | 23 | }↵
|
|
24 | public boolean isEmpty() {↵ | | 24 | public boolean isEmpty() {↵
|
25 | return set.isEmpty();↵ | | 25 | return set.isEmpty();↵
|
26 | }↵ | | 26 | }↵
|
|
27 | public Iterator iterator() {↵ | | 27 | public Iterator iterator() {↵
|
28 | return new IteratorProxy( set.iterator() );↵ | | 28 | return new EntryIteratorProxy( set.iterator() );↵
|
29 | }↵ | | 29 | }↵
|
|
30 | public boolean remove(Object o) {↵ | | 30 | public boolean remove(Object entry) {↵
|
31 | write();↵ | | 31 | write();↵
|
32 | return set.remove(o);↵ | | 32 | return set.remove(entry);↵
|
33 | }↵ | | 33 | }↵
|
|
34 | public boolean removeAll(Collection c) {↵ | | 34 | public boolean removeAll(Collection entries) {↵
|
35 | write();↵ | | 35 | write();↵
|
36 | return set.removeAll(c);↵ | | 36 | return set.removeAll(entries);↵
|
37 | }↵ | | 37 | }↵
|
|
38 | public boolean retainAll(Collection c) {↵ | | 38 | public boolean retainAll(Collection entries) {↵
|
39 | write();↵ | | 39 | write();↵
|
40 | return set.retainAll(c);↵ | | 40 | return set.retainAll(entries);↵
|
41 | }↵ | | 41 | }↵
|
|
42 | public int size() {↵ | | 42 | public int size() {↵
|
43 | return set.size();↵ | | 43 | return set.size();↵
|
44 | }↵ | | 44 | }↵
|
| | | 45 | // amazingly, these two will work because AbstractCollection↵
|
| | | 46 | // uses iterator() to fill the array↵
|
45 | public Object[] toArray() {↵ | | 47 | public Object[] toArray() {↵
|
46 | return set.toArray();↵ | | 48 | return set.toArray();↵
|
47 | }↵ | | 49 | }↵
|
|
48 | public Object[] toArray(Object[] array) {↵ | | 50 | public Object[] toArray(Object[] array) {↵
|
49 | return set.toArray(array);↵ | | 51 | return set.toArray(array);↵
|
50 | | | 52 |
|