mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-09 19:57:57 +01:00
Add CollectionUtils.addAll(iterator, collection)
This commit is contained in:
parent
51baa0e5cb
commit
77d010ec94
1 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,7 @@ package org.pgpainless.util;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -60,4 +61,17 @@ public final class CollectionUtils {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all items from the iterator to the collection.
|
||||||
|
*
|
||||||
|
* @param <T> type of item
|
||||||
|
* @param iterator iterator to gather items from
|
||||||
|
* @param collection collection to add items to
|
||||||
|
*/
|
||||||
|
public static <T> void addAll(Iterator<T> iterator, Collection<T> collection) {
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
collection.add(iterator.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue