MCPcopy Create free account
hub / github.com/davidgiven/luje / growAtEnd

Method growAtEnd

lib/java/util/ArrayList.java:347–376  ·  view source on GitHub ↗
(int required)

Source from the content-addressed store, hash-verified

345 }
346
347 private void growAtEnd(int required) {
348 if (array.length - size >= required) {
349 // REVIEW: as growAtEnd, why not move size == 0 out as
350 // special case
351 if (size != 0) {
352 System.arraycopy(array, firstIndex, array, 0, size);
353 int start = size < firstIndex ? firstIndex : size;
354 // REVIEW: I think we null too much
355 // array.length should be lastIndex ?
356 Arrays.fill(array, start, array.length, null);
357 }
358 firstIndex = 0;
359 } else {
360 // REVIEW: If size is 0?
361 // Does size/2 seems a little high!
362 int increment = size / 2;
363 if (required > increment) {
364 increment = required;
365 }
366 if (increment < 12) {
367 increment = 12;
368 }
369 E[] newArray = newElementArray(size + increment);
370 if (size != 0) {
371 System.arraycopy(array, firstIndex, newArray, 0, size);
372 firstIndex = 0;
373 }
374 array = newArray;
375 }
376 }
377
378 private void growAtFront(int required) {
379 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