116 |
// Must explicitly check, to get correct exception. |
// Must explicitly check, to get correct exception. |
117 |
if (capacity < 0) |
if (capacity < 0) |
118 |
throw new IllegalArgumentException(); |
throw new IllegalArgumentException(); |
119 |
data = new E[capacity]; |
data = (E[]) new Object[capacity]; |
120 |
} |
} |
121 |
|
|
122 |
/** |
/** |
151 |
// so don't update modCount. |
// so don't update modCount. |
152 |
if (size != data.length) |
if (size != data.length) |
153 |
{ |
{ |
154 |
E[] newData = new E[size]; |
E[] newData = (E[]) new Object[size]; |
155 |
System.arraycopy(data, 0, newData, 0, size); |
System.arraycopy(data, 0, newData, 0, size); |
156 |
data = newData; |
data = newData; |
157 |
} |
} |
173 |
|
|
174 |
if (minCapacity > current) |
if (minCapacity > current) |
175 |
{ |
{ |
176 |
E[] newData = new E[Math.max(current * 2, minCapacity)]; |
E[] newData = (E[]) new Object[Math.max(current * 2, minCapacity)]; |
177 |
System.arraycopy(data, 0, newData, 0, size); |
System.arraycopy(data, 0, newData, 0, size); |
178 |
data = newData; |
data = newData; |
179 |
} |
} |
268 |
*/ |
*/ |
269 |
public Object[] toArray() |
public Object[] toArray() |
270 |
{ |
{ |
271 |
E[] array = new E[size]; |
E[] array = (E[]) new Object[size]; |
272 |
System.arraycopy(data, 0, array, 0, size); |
System.arraycopy(data, 0, array, 0, size); |
273 |
return array; |
return array; |
274 |
} |
} |
578 |
// the `size' field. |
// the `size' field. |
579 |
s.defaultReadObject(); |
s.defaultReadObject(); |
580 |
int capacity = s.readInt(); |
int capacity = s.readInt(); |
581 |
data = new E[capacity]; |
data = (E[]) new Object[capacity]; |
582 |
for (int i = 0; i < size; i++) |
for (int i = 0; i < size; i++) |
583 |
data[i] = (E) s.readObject(); |
data[i] = (E) s.readObject(); |
584 |
} |
} |