Removes all elements from this ArrayList, leaving it empty. @see #isEmpty @see #size
()
| 254 | * @see #size |
| 255 | */ |
| 256 | @Override |
| 257 | public void clear() { |
| 258 | if (size != 0) { |
| 259 | // REVIEW: Should we use Arrays.fill() instead of just |
| 260 | // allocating a new array? Should we use the same |
| 261 | // sized array? |
| 262 | Arrays.fill(array, firstIndex, firstIndex + size, null); |
| 263 | // REVIEW: Should the indexes point into the middle of the |
| 264 | // array rather than 0? |
| 265 | firstIndex = size = 0; |
| 266 | modCount++; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Returns a new {@code ArrayList} with the same elements, the same size and |