MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / addAll

Method addAll

vm/JavaAPI/src/java/util/Vector.java:170–196  ·  view source on GitHub ↗

Inserts the objects in the specified collection at the specified location in this vector. The objects are inserted in the order in which they are returned from the Collection iterator. The elements with an index equal or higher than location have their index increased by the size of the adde

(int location,
            Collection<? extends E> collection)

Source from the content-addressed store, hash-verified

168 * if {@code location < 0} or {@code location > size()}.
169 */
170 @Override
171 public synchronized boolean addAll(int location,
172 Collection<? extends E> collection) {
173 if (0 <= location && location <= elementCount) {
174 int size = collection.size();
175 if (size == 0) {
176 return false;
177 }
178 int required = size - (elementData.length - elementCount);
179 if (required > 0) {
180 growBy(required);
181 }
182 int count = elementCount - location;
183 if (count > 0) {
184 System.arraycopy(elementData, location, elementData, location
185 + size, count);
186 }
187 Iterator<? extends E> it = collection.iterator();
188 while (it.hasNext()) {
189 elementData[location++] = it.next();
190 }
191 elementCount += size;
192 modCount++;
193 return true;
194 }
195 throw new ArrayIndexOutOfBoundsException(location);
196 }
197
198 /**
199 * Adds the objects in the specified collection to the end of this vector.

Callers 1

LivePreviewMethod · 0.95

Calls 6

growByMethod · 0.95
arraycopyMethod · 0.95
sizeMethod · 0.65
iteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected