Java Iterator addAll(Iterator source, U target)

Here you can find the source of addAll(Iterator source, U target)

Description

Add all items in iterator to target collection

License

Open Source License

Parameter

Parameter Description
T a parameter
U a parameter
source a parameter
target a parameter

Declaration

public static <T, U extends Collection<T>> U addAll(Iterator<T> source,
        U target) 

Method Source Code

//package com.java2s;
// License & terms of use: http://www.unicode.org/copyright.html#License

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**/* www.  j  a  v a 2s  .  co  m*/
     * Add all items in iterator to target collection
     * @param <T>
     * @param <U>
     * @param source
     * @param target
     * @return
     */
    public static <T, U extends Collection<T>> U addAll(Iterator<T> source,
            U target) {
        while (source.hasNext()) {
            target.add(source.next());
        }
        return target; // for chaining
    }
}

Related

  1. addAll(Collection dest, Iterator src)
  2. addAll(Collection dest, Iterator src)
  3. addAll(final C collection, final Iterator iter)
  4. addAll(final Collection targetCollection, final Iterator sourceIterator)
  5. addAll(Iterator iteratorFrom, Collection collectionTo)
  6. addAll(List target, Iterator source)
  7. addAll(Set s, Iterator i)
  8. addAllFromIterator( COLL dest, Iterator source)
  9. addAllToList(Iterator i)