(int required)
| 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) { |
no test coverage detected