Attempts to add all of the objects contained in collection to the contents of this Collection (optional). This implementation iterates over the given Collection and calls add for each element. If any of these calls return true, then true is returned as
(Collection<? extends E> collection)
| 71 | * such elements. |
| 72 | */ |
| 73 | public boolean addAll(Collection<? extends E> collection) { |
| 74 | boolean result = false; |
| 75 | Iterator<? extends E> it = collection.iterator(); |
| 76 | while (it.hasNext()) { |
| 77 | if (add(it.next())) { |
| 78 | result = true; |
| 79 | } |
| 80 | } |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Removes all elements from this {@code Collection}, leaving it empty (optional). |