1 19 package bak.pcj; 20 21 import bak.pcj.util.Exceptions; 22 23 34 public class SynchronizedCharCollection implements CharCollection { 35 36 37 protected CharCollection collection; 38 39 40 protected Object m; 41 42 54 public SynchronizedCharCollection(CharCollection c) { 55 if (c == null) 56 Exceptions.nullArgument("collection"); 57 this.collection = c; 58 this.m = this; 59 } 60 61 public boolean add(char v) 62 { synchronized (m) { return collection.add(v); } } 63 64 public boolean addAll(CharCollection c) 65 { synchronized (m) { return collection.addAll(c); } } 66 67 public void clear() 68 { synchronized (m) { collection.clear(); } } 69 70 public boolean contains(char v) 71 { synchronized (m) { return collection.contains(v); } } 72 73 public boolean containsAll(CharCollection 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 CharIterator iterator() 86 { synchronized (m) { return collection.iterator(); } } 87 88 public boolean remove(char v) 89 { synchronized (m) { return collection.remove(v); } } 90 91 public boolean removeAll(CharCollection c) 92 { synchronized (m) { return collection.removeAll(c); } } 93 94 public boolean retainAll(CharCollection c) 95 { synchronized (m) { return collection.retainAll(c); } } 96 97 public int size() 98 { synchronized (m) { return collection.size(); } } 99 100 public char[] toArray() 101 { synchronized (m) { return collection.toArray(); } } 102 103 public char[] toArray(char[] a) 104 { synchronized (m) { return collection.toArray(a); } } 105 106 public void trimToSize() 107 { synchronized (m) { collection.trimToSize(); } } 108 109 } | Popular Tags |