Here you can find the source of addAll(final Collection super T> targetCollection, final Iterator extends T> sourceIterator)
Parameter | Description |
---|---|
targetCollection | the Collection where to add the elements |
sourceIterator | the Iterator where to get the elements from |
T | the type of elements to transfer |
public static <T> void addAll(final Collection<? super T> targetCollection, final Iterator<? extends T> sourceIterator)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; public class Main { /**/*from w w w . j a va2 s . c o m*/ * Adds all elements that a given {@link Iterator} provides to a given * {@link Collection} of appropriate type * * @param targetCollection * the {@link Collection} where to add the elements * @param sourceIterator * the {@link Iterator} where to get the elements from * @param <T> * the type of elements to transfer */ public static <T> void addAll(final Collection<? super T> targetCollection, final Iterator<? extends T> sourceIterator) { while (sourceIterator.hasNext()) { targetCollection.add(sourceIterator.next()); } } }