(int required)
| 376 | } |
| 377 | |
| 378 | private void growAtFront(int required) { |
| 379 | if (array.length - size >= required) { |
| 380 | int newFirst = array.length - size; |
| 381 | // REVIEW: as growAtEnd, why not move size == 0 out as |
| 382 | // special case |
| 383 | if (size != 0) { |
| 384 | System.arraycopy(array, firstIndex, array, newFirst, size); |
| 385 | int lastIndex = firstIndex + size; |
| 386 | int length = lastIndex > newFirst ? newFirst : lastIndex; |
| 387 | Arrays.fill(array, firstIndex, length, null); |
| 388 | } |
| 389 | firstIndex = newFirst; |
| 390 | } else { |
| 391 | int increment = size / 2; |
| 392 | if (required > increment) { |
| 393 | increment = required; |
| 394 | } |
| 395 | if (increment < 12) { |
| 396 | increment = 12; |
| 397 | } |
| 398 | E[] newArray = newElementArray(size + increment); |
| 399 | if (size != 0) { |
| 400 | System.arraycopy(array, firstIndex, newArray, increment, size); |
| 401 | } |
| 402 | firstIndex = newArray.length - size; |
| 403 | array = newArray; |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | private void growForInsert(int location, int required) { |
| 408 | // REVIEW: we grow too quickly because we are called with the |
no test coverage detected