1 19 package bak.pcj; 20 21 import bak.pcj.util.Exceptions; 22 23 34 public class SynchronizedIntCollection implements IntCollection { 35 36 37 protected IntCollection collection; 38 39 40 protected Object m; 41 42 54 public SynchronizedIntCollection(IntCollection c) { 55 if (c == null) 56 Exceptions.nullArgument("collection"); 57 this.collection = c; 58 this.m = this; 59 } 60 61 public boolean add(int v) 62 { synchronized (m) { return collection.add(v); } } 63 64 public boolean addAll(IntCollection c) 65 { synchronized (m) { return collection.addAll(c); } } 66 67 public void clear() 68 { synchronized (m) { collection.clear(); } } 69 70 public boolean contains(int v) 71 { synchronized (m) { return collection.contains(v); } } 72 73 public boolean containsAll(IntCollection c) 74 { synchronized (m) { return collection.containsAll(c); } } 75 76 public boolean equals(Object obj) 77 { synchronized (m) { return collection.equals(obj); } } 78 79 public int hashCode() 80 { synchronized(m) { return collection.hashCode(); } } 81 82 public boolean isEmpty() 83 { synchronized (m) { return collection.isEmpty(); } } 84 85 public IntIterator iterator() 86 { synchronized (m) { return collection.iterator(); } } 87 88 public boolean remove(int v) 89 { synchronized (m) { return collection.remove(v); } } 90 91 public boolean removeAll(IntCollection c) 92 { synchronized (m) { return collection.removeAll(c); } } 93 94 public boolean retainAll(IntCollection c) 95 { synchronized (m) { return collection.retainAll(c); } } 96 97 public int size() 98 { synchronized (m) { return collection.size(); } } 99 100 public int[] toArray() 101 { synchronized (m) { return collection.toArray(); } } 102 103 public int[] toArray(int[] a) 104 { synchronized (m) { return collection.toArray(a); } } 105 106 public void trimToSize() 107 { synchronized (m) { collection.trimToSize(); } } 108 109 } | Popular Tags |