Removes all occurrences in this collection which are contained in the specified collection. @param collection the collection of objects to remove. @return true if this collection was modified, false otherwise. @throws UnsupportedOperationException i
(Collection<?> collection)
| 95 | * if removing from this collection is not supported. |
| 96 | */ |
| 97 | @Override |
| 98 | public boolean removeAll(Collection<?> collection) { |
| 99 | boolean result = false; |
| 100 | if (size() <= collection.size()) { |
| 101 | Iterator<?> it = iterator(); |
| 102 | while (it.hasNext()) { |
| 103 | if (collection.contains(it.next())) { |
| 104 | it.remove(); |
| 105 | result = true; |
| 106 | } |
| 107 | } |
| 108 | } else { |
| 109 | Iterator<?> it = collection.iterator(); |
| 110 | while (it.hasNext()) { |
| 111 | result = remove(it.next()) || result; |
| 112 | } |
| 113 | } |
| 114 | return result; |
| 115 | } |
| 116 | } |