public class Iterators extends Object
| Constructor and Description |
|---|
Iterators() |
| Modifier and Type | Method and Description |
|---|---|
static <E,C extends Collection<E>> |
addAll(Iterator<? extends E> iter,
C collection)
Adds all elements from the supplied iterator to the specified collection.
|
static void |
closeCloseable(Iterator<?> iter)
Closes the supplied iterator if it is an instance of
ClosableIterator, otherwise the request is ignored. |
static int |
count(Iterator<?> it)
Runs through the iterator and returns number of items.
|
static String |
toString(Iterator<?> iter,
String separator)
Converts an iterator to a string by concatenating all of the string
representations of objects in the iterator, divided by a separator.
|
static void |
toString(Iterator<?> iter,
String separator,
StringBuilder sb)
Converts an iterator to a string by concatenating all of the string
representations of objects in the iterator, divided by a separator.
|
public static <E,C extends Collection<E>> C addAll(Iterator<? extends E> iter, C collection)
ClosableIterator it is
automatically closed after consumption.iter - An iterator containing elements to add to the container. If
the iterator is an instance of ClosableIterator it is
automatically closed after consumption.collection - The collection to add the elements to.public static void closeCloseable(Iterator<?> iter)
ClosableIterator, otherwise the request is ignored.iter - The iterator that should be closed.public static String toString(Iterator<?> iter, String separator)
iter - An iterator over arbitrary objects that are expected to
implement Object.toString().separator - The separator to insert between the object strings.public static void toString(Iterator<?> iter, String separator, StringBuilder sb)
iter - An iterator over arbitrary objects that are expected to
implement Object.toString().separator - The separator to insert between the object strings.sb - A StringBuilder to append the iterator string to.public static int count(Iterator<?> it)
it - Any type of iterator, not nullCopyright © 2005–2016 IT-Consulting Dr. Max V?lkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.