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

Method growAtEnd

vm/JavaAPI/src/java/util/ArrayList.java:333–362  ·  view source on GitHub ↗
(int required)

Source from the content-addressed store, hash-verified

331 }
332
333 private void growAtEnd(int required) {
334 if (array.length - size >= required) {
335 // REVIEW: as growAtEnd, why not move size == 0 out as
336 // special case
337 if (size != 0) {
338 System.arraycopy(array, firstIndex, array, 0, size);
339 int start = size < firstIndex ? firstIndex : size;
340 // REVIEW: I think we null too much
341 // array.length should be lastIndex ?
342 Arrays.fill(array, start, array.length, null);
343 }
344 firstIndex = 0;
345 } else {
346 // REVIEW: If size is 0?
347 // Does size/2 seems a little high!
348 int increment = size / 2;
349 if (required > increment) {
350 increment = required;
351 }
352 if (increment < 12) {
353 increment = 12;
354 }
355 E[] newArray = newElementArray(size + increment);
356 if (size != 0) {
357 System.arraycopy(array, firstIndex, newArray, 0, size);
358 firstIndex = 0;
359 }
360 array = newArray;
361 }
362 }
363
364 private void growAtFront(int required) {
365 if (array.length - size >= required) {

Callers 3

addMethod · 0.95
addAllMethod · 0.95
ensureCapacityMethod · 0.95

Calls 3

arraycopyMethod · 0.95
fillMethod · 0.95
newElementArrayMethod · 0.95

Tested by

no test coverage detected