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

Iteratordump(Iterator it)
dump
List<T> list = new ArrayList<T>();
while (it.hasNext()) {
    list.add(it.next());
System.out.println(list);
return list.iterator();
booleanendOfData(Iterator inputIter, Iterator resultIter)
end Of Data
return !resultIter.hasNext() || !inputIter.hasNext();
booleanequalsIterator(Iterator it, Iterator it2)
equals Iterator
if (it == it2)
    return true;
while (it.hasNext() && it2.hasNext()) {
    if (!it.next().equals(it2.next()))
        return false;
return !it.hasNext() && !it2.hasNext();
Sfill(final Iterator iterator, final S collection)
fill
while (iterator.hasNext()) {
    collection.add(iterator.next());
return collection;
voidfillArray(Iterator ii, Object[] fillMe, boolean null_terminate)
Fills an array with the contents of an iterator.
int i = 0;
int len = fillMe.length;
while (i < len && ii.hasNext())
    fillMe[i++] = ii.next();
if (null_terminate && i < len)
    fillMe[i] = null;
voidfillCollection(final Iterator iterator, final Collection collection)
fill Collection
while (iterator.hasNext()) {
    collection.add(iterator.next());
voidfillCollection(final Iterator iterator, final Collection collection)
Drain an iterator into a collection.
try {
    while (true) {
        collection.add(iterator.next());
} catch (final NoSuchElementException e) {
TfirstOrDefault(Iterator iterator)
first Or Default
if (!iterator.hasNext()) {
    return null;
return iterator.next();
StringfmtSeq(Iterator it, String divider)
fmt Seq
String resString = new String();
boolean first = true;
while (it.hasNext()) {
    if (first)
        first = false;
    else
        resString += divider;
    resString += it.next();
...
SetfromIterator(Iterator iterator)
Create a set containing the elements of an iterator
Set l = set();
while (iterator.hasNext()) {
    l.add(iterator.next());
return l;