/interpreter/tags/reactive-pattern-matching/test/edu/vub/at/objects/natives/VectorProxy.java
Java | 202 lines | 151 code | 45 blank | 6 comment | 2 complexity | f3468d3792e6988fec88c152eaad42a8 MD5 | raw file
1/** 2 * 3 */ 4package edu.vub.at.objects.natives; 5 6import java.util.Collection; 7import java.util.Enumeration; 8import java.util.List; 9 10/** 11 * Auxiliary class which forwards all operations to the default Vector but has elementCount as a public field 12 */ 13public class VectorProxy { 14 public int elementCount; 15 16 private java.util.Vector impl; 17 18 public VectorProxy() { 19 impl = new java.util.Vector(); 20 } 21 22 public void add(int index, Object element) { 23 impl.add(index, element); 24 elementCount++; 25 } 26 27 public synchronized boolean add(Object o) { 28 elementCount++; 29 return impl.add(o); 30 } 31 32 public synchronized boolean addAll(Collection c) { 33 elementCount += c.size(); 34 return impl.addAll(c); 35 } 36 37 public synchronized boolean addAll(int index, Collection c) { 38 elementCount += c.size(); 39 return impl.addAll(index, c); 40 } 41 42 public synchronized void addElement(Object obj) { 43 elementCount++; 44 impl.addElement(obj); 45 } 46 47 public int capacity() { 48 return impl.capacity(); 49 } 50 51 public void clear() { 52 elementCount = 0; 53 impl.clear(); 54 } 55 56 public synchronized Object clone() { 57 return impl.clone(); 58 } 59 60 public boolean contains(Object elem) { 61 return impl.contains(elem); 62 } 63 64 public synchronized boolean containsAll(Collection c) { 65 return impl.containsAll(c); 66 } 67 68 public synchronized void copyInto(Object[] anArray) { 69 impl.copyInto(anArray); 70 } 71 72 public synchronized Object elementAt(int index) { 73 return impl.elementAt(index); 74 } 75 76 public Enumeration elements() { 77 return impl.elements(); 78 } 79 80 public synchronized void ensureCapacity(int minCapacity) { 81 impl.ensureCapacity(minCapacity); 82 } 83 84 public synchronized boolean equals(Object o) { 85 return impl.equals(o); 86 } 87 88 public synchronized Object firstElement() { 89 return impl.firstElement(); 90 } 91 92 public synchronized Object get(int index) { 93 return impl.get(index); 94 } 95 96 public synchronized int hashCode() { 97 return impl.hashCode(); 98 } 99 100 public synchronized int indexOf(Object elem, int index) { 101 return impl.indexOf(elem, index); 102 } 103 104 public int indexOf(Object elem) { 105 return impl.indexOf(elem); 106 } 107 108 public synchronized void insertElementAt(Object obj, int index) { 109 impl.insertElementAt(obj, index); 110 } 111 112 public boolean isEmpty() { 113 return impl.isEmpty(); 114 } 115 116 public synchronized Object lastElement() { 117 return impl.lastElement(); 118 } 119 120 public synchronized int lastIndexOf(Object elem, int index) { 121 return impl.lastIndexOf(elem, index); 122 } 123 124 public int lastIndexOf(Object elem) { 125 return impl.lastIndexOf(elem); 126 } 127 128 public synchronized Object remove(int index) { 129 elementCount--; 130 return impl.remove(index); 131 } 132 133 public boolean remove(Object o) { 134 boolean result = impl.remove(o); 135 if(result) elementCount--; 136 return result; 137 } 138 139 public synchronized boolean removeAll(Collection c) { 140 boolean result = impl.removeAll(c); 141 elementCount = impl.size(); 142 return result; 143 } 144 145 public synchronized void removeAllElements() { 146 elementCount = 0; 147 impl.removeAllElements(); 148 } 149 150 public synchronized boolean removeElement(Object obj) { 151 boolean result = impl.removeElement(obj); 152 if(result) elementCount--; 153 return result; 154 } 155 156 public synchronized void removeElementAt(int index) { 157 elementCount--; 158 impl.removeElementAt(index); 159 } 160 161 public synchronized boolean retainAll(Collection c) { 162 boolean result = impl.retainAll(c); 163 elementCount = impl.size(); 164 return result; 165 } 166 167 public synchronized Object set(int index, Object element) { 168 return impl.set(index, element); 169 } 170 171 public synchronized void setElementAt(Object obj, int index) { 172 impl.setElementAt(obj, index); 173 } 174 175 public synchronized void setSize(int newSize) { 176 impl.setSize(newSize); 177 } 178 179 public int size() { 180 return impl.size(); 181 } 182 183 public List subList(int fromIndex, int toIndex) { 184 return impl.subList(fromIndex, toIndex); 185 } 186 187 public synchronized Object[] toArray() { 188 return impl.toArray(); 189 } 190 191 public synchronized Object[] toArray(Object[] a) { 192 return impl.toArray(a); 193 } 194 195 public synchronized String toString() { 196 return impl.toString(); 197 } 198 199 public synchronized void trimToSize() { 200 impl.trimToSize(); 201 } 202}