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