List of utility methods to do Iterator
List | fromIterator(Iterator iterator) Create a list containing the elements of an iterator List<Object> l = list(); while (iterator.hasNext()) { l.add(iterator.next()); return l; |
Set | fromIterator(Iterator from Iterator Set<E> set = new HashSet<E>(); while (itr.hasNext()) { set.add(itr.next()); return set; |
T | get(Iterator get for (int i = 0; i < position; i++) { iterator.next(); return iterator.next(); |
int | getEnumeratedObjectCount(Iterator * Gets the enumerated object count. int count = 0; while (objects != null && objects.hasNext()) { @SuppressWarnings("unused") Object obj = objects.next(); count++; return count; |
Enumeration | getEnumeration(Iterator i) get Enumeration Vector v = new Vector(); while (i.hasNext()) v.addElement(i.next()); return v.elements(); |
Enumeration | getIteratorEnumeration(final Iterator i) get Iterator Enumeration return new Enumeration() { public boolean hasMoreElements() { return i.hasNext(); public Object nextElement() { return i.next(); }; ... |
Object | getObjectAtIteratorPos(Iterator> i, int pos) Given a numeric position, cycle through the given Iterator until the position is reached, and return the Object found there. int currPos = 0; Object oc; while (i.hasNext()) { oc = i.next(); if (currPos == pos) return oc; else currPos++; ... |
boolean | hasNext(final Iterator> i) has Next return (i != null) && i.hasNext();
|
boolean | hasNext(final Iterator> it) Asks an iterator if there is next value. return it != null && it.hasNext();
|
boolean | hasNextIteration(final Iterator iterator) has Next Iteration if (iterator.hasNext()) { while (iterator.hasNext()) { iterator.next(); return true; } else { return false; |