1 19 package bak.pcj; 20 21 import bak.pcj.util.Exceptions; 22 23 32 public class UnmodifiableDoubleCollection implements DoubleCollection { 33 34 35 protected DoubleCollection collection; 36 37 49 public UnmodifiableDoubleCollection(DoubleCollection c) { 50 if (c == null) 51 Exceptions.nullArgument("collection"); 52 this.collection = c; 53 } 54 55 61 public boolean add(double v) 62 { Exceptions.unsupported("add"); throw new RuntimeException (); } 63 64 70 public boolean addAll(DoubleCollection c) 71 { Exceptions.unsupported("addAll"); throw new RuntimeException (); } 72 73 79 public void clear() 80 { Exceptions.unsupported("clear"); } 81 82 public boolean contains(double v) 83 { return collection.contains(v); } 84 85 public boolean containsAll(DoubleCollection c) 86 { return collection.containsAll(c); } 87 88 public boolean equals(Object obj) 89 { return collection.equals(obj); } 90 91 public int hashCode() 92 { return collection.hashCode(); } 93 94 public boolean isEmpty() 95 { return collection.isEmpty(); } 96 97 public DoubleIterator iterator() { 98 final DoubleIterator i = collection.iterator(); 99 return new DoubleIterator() { 100 public boolean hasNext() 101 { return i.hasNext(); } 102 103 public double next() 104 { return i.next(); } 105 106 public void remove() 110 { Exceptions.unsupported("remove"); } 111 }; 112 } 113 114 120 public boolean remove(double v) 121 { Exceptions.unsupported("remove"); throw new RuntimeException (); } 122 123 129 public boolean removeAll(DoubleCollection c) 130 { Exceptions.unsupported("removeAll"); throw new RuntimeException (); } 131 132 138 public boolean retainAll(DoubleCollection c) 139 { Exceptions.unsupported("retainAll"); throw new RuntimeException (); } 140 141 public int size() 142 { return collection.size(); } 143 144 public double[] toArray() 145 { return collection.toArray(); } 146 147 public double[] toArray(double[] a) 148 { return collection.toArray(a); } 149 150 public void trimToSize() 151 { } 152 153 } | Popular Tags |