Here you can find the source of addAll(Collection
Parameter | Description |
---|---|
E | element class. |
coll | the collection to which the elements are added. |
it | the iterable providing the elements to add. |
true
if the collection was modified, false
otherwise.
public static <E> boolean addAll(Collection<E> coll, Iterable<? extends E> it)
//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; } }