260 |
*/ |
*/ |
261 |
public boolean removeAll(Collection c) |
public boolean removeAll(Collection c) |
262 |
{ |
{ |
263 |
|
return removeAllInternal(c); |
264 |
|
} |
265 |
|
|
266 |
|
/** |
267 |
|
* Remove from this collection all its elements that are contained in a given |
268 |
|
* collection (optional operation). This implementation iterates over this |
269 |
|
* collection, and for each element tests if it is contained in the given |
270 |
|
* collection. If so, it is removed by the Iterator's remove method (thus |
271 |
|
* this method will fail with an UnsupportedOperationException if the |
272 |
|
* Iterator's remove method does). This method is necessary for ArrayList, |
273 |
|
* which cannot publicly override removeAll but can optimize this call. |
274 |
|
* |
275 |
|
* @param c the collection to remove the elements of |
276 |
|
* @return true if the remove operation caused the Collection to change |
277 |
|
* @throws UnsupportedOperationException if this collection's Iterator |
278 |
|
* does not support the remove method |
279 |
|
* @see Iterator#remove() |
280 |
|
*/ |
281 |
|
boolean removeAllInternal(Collection c) |
282 |
|
{ |
283 |
Iterator itr = iterator(); |
Iterator itr = iterator(); |
284 |
boolean modified = false; |
boolean modified = false; |
285 |
int pos = size(); |
int pos = size(); |
308 |
*/ |
*/ |
309 |
public boolean retainAll(Collection c) |
public boolean retainAll(Collection c) |
310 |
{ |
{ |
311 |
|
return retainAllInternal(c); |
312 |
|
} |
313 |
|
|
314 |
|
/** |
315 |
|
* Remove from this collection all its elements that are not contained in a |
316 |
|
* given collection (optional operation). This implementation iterates over |
317 |
|
* this collection, and for each element tests if it is contained in the |
318 |
|
* given collection. If not, it is removed by the Iterator's remove method |
319 |
|
* (thus this method will fail with an UnsupportedOperationException if |
320 |
|
* the Iterator's remove method does). This method is necessary for |
321 |
|
* ArrayList, which cannot publicly override retainAll but can optimize |
322 |
|
* this call. |
323 |
|
* |
324 |
|
* @param c the collection to retain the elements of |
325 |
|
* @return true if the remove operation caused the Collection to change |
326 |
|
* @throws UnsupportedOperationException if this collection's Iterator |
327 |
|
* does not support the remove method |
328 |
|
* @see Iterator#remove() |
329 |
|
*/ |
330 |
|
boolean retainAllInternal(Collection c) |
331 |
|
{ |
332 |
Iterator itr = iterator(); |
Iterator itr = iterator(); |
333 |
boolean modified = false; |
boolean modified = false; |
334 |
int pos = size(); |
int pos = size(); |