129 |
public Vector(Collection<? extends T> c) |
public Vector(Collection<? extends T> c) |
130 |
{ |
{ |
131 |
elementCount = c.size(); |
elementCount = c.size(); |
132 |
elementData = c.toArray(new T[elementCount]); |
elementData = c.toArray((T[]) new Object[elementCount]); |
133 |
} |
} |
134 |
|
|
135 |
/** |
/** |
145 |
{ |
{ |
146 |
if (initialCapacity < 0) |
if (initialCapacity < 0) |
147 |
throw new IllegalArgumentException(); |
throw new IllegalArgumentException(); |
148 |
elementData = new T[initialCapacity]; |
elementData = (T[]) new Object[initialCapacity]; |
149 |
this.capacityIncrement = capacityIncrement; |
this.capacityIncrement = capacityIncrement; |
150 |
} |
} |
151 |
|
|
188 |
// vector since that is a much less likely case; it's more efficient to |
// vector since that is a much less likely case; it's more efficient to |
189 |
// not do the check and lose a bit of performance in that infrequent case |
// not do the check and lose a bit of performance in that infrequent case |
190 |
|
|
191 |
T[] newArray = new T[elementCount]; |
T[] newArray = (T[]) new Object[elementCount]; |
192 |
System.arraycopy(elementData, 0, newArray, 0, elementCount); |
System.arraycopy(elementData, 0, newArray, 0, elementCount); |
193 |
elementData = newArray; |
elementData = newArray; |
194 |
} |
} |
214 |
else |
else |
215 |
newCapacity = elementData.length + capacityIncrement; |
newCapacity = elementData.length + capacityIncrement; |
216 |
|
|
217 |
T[] newArray = new T[Math.max(newCapacity, minCapacity)]; |
T[] newArray = (T[]) new Object[Math.max(newCapacity, minCapacity)]; |
218 |
|
|
219 |
System.arraycopy(elementData, 0, newArray, 0, elementCount); |
System.arraycopy(elementData, 0, newArray, 0, elementCount); |
220 |
elementData = newArray; |
elementData = newArray; |
778 |
public synchronized boolean addAll(int index, Collection<? extends T> c) |
public synchronized boolean addAll(int index, Collection<? extends T> c) |
779 |
{ |
{ |
780 |
checkBoundInclusive(index); |
checkBoundInclusive(index); |
781 |
Iterator itr = c.iterator(); |
Iterator<? extends T> itr = c.iterator(); |
782 |
int csize = c.size(); |
int csize = c.size(); |
783 |
|
|
784 |
modCount++; |
modCount++; |