/[classpath]/classpath/java/util/AbstractCollection.java
ViewVC logotype

Diff of /classpath/java/util/AbstractCollection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by ericb, Fri Oct 19 00:17:44 2001 UTC revision 1.11 by ericb, Thu Oct 25 07:34:19 2001 UTC
# Line 260  public abstract class AbstractCollection Line 260  public abstract class AbstractCollection
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();
# Line 288  public abstract class AbstractCollection Line 308  public abstract class AbstractCollection
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();

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26