Java Utililty Methods Iterator

List of utility methods to do Iterator

Description

The list of methods to do Iterator are organized into topic(s).

Method

voidaddAll(Collection dest, Iterator src)
Adds all the elements from an iterator to a collection.
while (src.hasNext())
    dest.add(src.next());
voidaddAll(Collection dest, Iterator src)
add All
if (src != null) {
    while (src.hasNext()) {
        T value = src.next();
        dest.add(value);
CaddAll(final C collection, final Iterator iter)
adds all elements from iter to collection
while (iter.hasNext()) {
    collection.add(iter.next());
return collection;
voidaddAll(final Collection targetCollection, final Iterator sourceIterator)
Adds all elements that a given Iterator provides to a given Collection of appropriate type
while (sourceIterator.hasNext()) {
    targetCollection.add(sourceIterator.next());
voidaddAll(Iterator iteratorFrom, Collection collectionTo)
If the given Iterator is not null, iterate over all T elements in it and add them to the given Collection.
if (iteratorFrom != null) {
    while (iteratorFrom.hasNext()) {
        collectionTo.add(iteratorFrom.next());
UaddAll(Iterator source, U target)
Add all items in iterator to target collection
while (source.hasNext()) {
    target.add(source.next());
return target; 
ListaddAll(List target, Iterator source)
add All
if (source == null)
    return target;
for (; source.hasNext(); target.add(source.next()))
    ;
return target;
voidaddAll(Set s, Iterator i)
add All
while (i != null && i.hasNext()) {
    s.add(i.next());
COLLaddAllFromIterator(COLL dest, Iterator source)
add All From Iterator
while (source.hasNext()) {
    dest.add(source.next());
return dest;
LinkedListaddAllToList(Iterator i)
Adds all elements of iterator's range to a new linked list.
LinkedList<T> result = new LinkedList<T>();
while (i.hasNext()) {
    result.add(i.next());
return result;