Java Iterator appendTo(final Iterator iter, final List list)

Here you can find the source of appendTo(final Iterator iter, final List list)

Description

Appends all elements which the iterator is willing to produce to the given list.

License

Apache License

Parameter

Parameter Description
iter the iterator
list the list

Declaration

public static <T> void appendTo(final Iterator<T> iter, final List<T> list) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;
import java.util.List;

public class Main {
    /**//from ww w. ja  va 2s  . c  o  m
     * Appends all elements which the iterator is willing to produce to the
     * given list.
     *
     * @param iter
     *            the iterator
     * @param list
     *            the list
     */
    public static <T> void appendTo(final Iterator<T> iter, final List<T> list) {
        assert null != iter;
        assert null != list;

        while (iter.hasNext()) {
            list.add(iter.next());
        }
    }
}

Related

  1. addAll(Set s, Iterator i)
  2. addAllFromIterator( COLL dest, Iterator source)
  3. addAllToList(Iterator i)
  4. addAllToSet(Set set, Iterator it)
  5. addTo(final Iterator iter, final C c)
  6. areEqual(final Iterator a, final Iterator b)
  7. areEqual(final Iterator ittyA, final Iterator ittyB)
  8. asArray(T[] arr, Iterator itr)
  9. asList(final Iterator iterator)