1 16 package java.util; 17 18 import com.google.gwt.core.client.JavaScriptObject; 19 20 38 public class ArrayList extends AbstractList implements List , Cloneable , 39 RandomAccess { 40 50 51 protected static boolean equals(Object a, Object b) { 52 return (a == null ? b == null : a.equals(b)); 53 } 54 58 transient JavaScriptObject array; 59 63 int endIndex; 64 68 int startIndex; 69 70 public ArrayList() { 71 initArray(); 72 } 73 74 public ArrayList(Collection c) { 75 initArray(); 76 addAll(c); 77 } 78 79 84 public ArrayList(int initialCapacity) { 85 this(); 88 } 89 90 public native void add(int index, Object o) ; 115 116 public boolean add(Object o) { 117 add(size(),o); 118 return true; 119 } 120 121 public void clear() { 122 setSize(0); 123 } 124 125 public Object clone() { 126 return new ArrayList (this); 127 } 128 129 public boolean contains(Object o) { 130 return (indexOf(o) != -1); 131 } 132 133 public native Object get(int index) ; 138 139 public int indexOf(Object o) { 140 return indexOf(o, 0); 141 } 142 143 public native boolean isEmpty() ; 146 147 public int lastIndexOf(Object o) { 148 return lastIndexOf(o, size() - 1); 149 } 150 151 public Object remove(int index) { 152 Object old = get(index); 153 removeRange(index,index + 1); 154 return old; 155 } 156 157 public boolean remove(Object o) { 158 int i = indexOf(o); 159 if (i == -1) { 160 return false; 161 } 162 remove(i); 163 return true; 164 } 165 166 public native Object set(int index, Object o) ; 174 175 public native int size() ; 178 179 protected native void removeRange(int fromIndex, int toIndex) ; 204 205 native int indexOf(Object o, int index) ; 218 219 223 void indexOutOfBounds(int i) { 224 throw new IndexOutOfBoundsException ("Size: " + this.size() + " Index: " + i); 225 } 226 227 231 native int lastIndexOf(Object o, int index) ; 243 244 247 native void setSize(int newSize) ; 265 266 native void verifyIndex(int index) ; 273 274 native void verifyIndexOneExtra(int index) ; 281 282 private native void initArray() ; 289 } 290 | Popular Tags |