1 13 14 package EDU.oswego.cs.dl.util.concurrent; 15 import java.util.*; 16 17 65 66 67 public class CopyOnWriteArraySet extends AbstractSet implements Cloneable , java.io.Serializable { 68 69 protected final CopyOnWriteArrayList al; 70 71 74 public CopyOnWriteArraySet() { 75 al = new CopyOnWriteArrayList(); 76 } 77 78 82 public CopyOnWriteArraySet(Collection c) { 83 al = new CopyOnWriteArrayList(); 84 al.addAllAbsent(c); 85 } 86 87 88 public int size() { return al.size(); } 89 public boolean isEmpty() { return al.isEmpty(); } 90 public boolean contains(Object o) { return al.contains(o); } 91 public Object [] toArray() { return al.toArray(); } 92 public Object [] toArray(Object [] a) { return al.toArray(a); } 93 public void clear() { al.clear(); } 94 public Iterator iterator() { return al.iterator(); } 95 public boolean remove(Object o) { return al.remove(o); } 96 public boolean containsAll(Collection c) { return al.containsAll(c); } 97 public boolean addAll(Collection c) { return al.addAllAbsent(c) > 0; } 98 public boolean removeAll(Collection c) { return al.removeAll(c); } 99 public boolean retainAll(Collection c) { return al.retainAll(c); } 100 public boolean add(Object o) { return al.addIfAbsent(o); } 101 102 } 103 | Popular Tags |