(int required)
| 362 | } |
| 363 | |
| 364 | private void growAtFront(int required) { |
| 365 | if (array.length - size >= required) { |
| 366 | int newFirst = array.length - size; |
| 367 | // REVIEW: as growAtEnd, why not move size == 0 out as |
| 368 | // special case |
| 369 | if (size != 0) { |
| 370 | System.arraycopy(array, firstIndex, array, newFirst, size); |
| 371 | int lastIndex = firstIndex + size; |
| 372 | int length = lastIndex > newFirst ? newFirst : lastIndex; |
| 373 | Arrays.fill(array, firstIndex, length, null); |
| 374 | } |
| 375 | firstIndex = newFirst; |
| 376 | } else { |
| 377 | int increment = size / 2; |
| 378 | if (required > increment) { |
| 379 | increment = required; |
| 380 | } |
| 381 | if (increment < 12) { |
| 382 | increment = 12; |
| 383 | } |
| 384 | E[] newArray = newElementArray(size + increment); |
| 385 | if (size != 0) { |
| 386 | System.arraycopy(array, firstIndex, newArray, increment, size); |
| 387 | } |
| 388 | firstIndex = newArray.length - size; |
| 389 | array = newArray; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | private void growForInsert(int location, int required) { |
| 394 | // REVIEW: we grow too quickly because we are called with the |
no test coverage detected