Java Collection Add addAll(Collection coll, Iterable it)

Here you can find the source of addAll(Collection coll, Iterable it)

Description

Adds all elements from an iterable to a collection.

License

Open Source License

Parameter

Parameter Description
E element class.
coll the collection to which the elements are added.
it the iterable providing the elements to add.

Return

true if the collection was modified, false otherwise.

Declaration

public static <E> boolean addAll(Collection<E> coll, Iterable<? extends E> it) 

Method Source Code

//package com.java2s;
/* Copyright (C) 2013 TU Dortmund
 * This file is part of AutomataLib, http://www.automatalib.net/.
 * /*from  w  w  w .ja  v a2 s.  co  m*/
 * AutomataLib is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 3.0 as published by the Free Software Foundation.
 * 
 * AutomataLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with AutomataLib; if not, see
 * http://www.gnu.de/documents/lgpl.en.html.
 */

import java.util.Collection;

public class Main {
    /**
     * Adds all elements from an iterable to a collection.
     * @param <E> element class.
     * @param coll the collection to which the elements are added.
     * @param it the iterable providing the elements to add.
     * @return <code>true</code> if the collection was modified,
     * <code>false</code> otherwise.
     */
    public static <E> boolean addAll(Collection<E> coll, Iterable<? extends E> it) {
        boolean modified = false;
        for (E e : it)
            modified = coll.add(e) || modified;
        return modified;
    }
}

Related

  1. addAll(Collection collection, Iterable toAdd)
  2. addAll(Collection addTo, Iterable elementsToAdd)
  3. addAll(Collection c, Iterable elts)
  4. addAll(Collection c, T... array)
  5. addAll(Collection c, T... array)
  6. addAll(Collection collection, E... args)
  7. addAll(Collection collection, Iterable iterable)
  8. addAll(Collection collection, Iterator iterator)
  9. addAll(Collection pCollection, Iterator pIterator)