Package org.scijava.util
Class IteratorPlus<E>
- java.lang.Object
-
- org.scijava.util.IteratorPlus<E>
-
- All Implemented Interfaces:
Iterable<E>,Enumeration<E>,Iterator<E>
public class IteratorPlus<E> extends Object implements Enumeration<E>, Iterator<E>, Iterable<E>
A class that provides more thorough support for iteration. AnyEnumeration,IteratororIterableobject can be provided to the constructor, and the resultantIteratorPluswill provide all three access mechanisms. In the case ofiterator()it simply returnsthis, for more convenient usage with for-each loops. Note, however, that because of this fact, multiple calls to {#iterator()} will produce the sameIteratorevery time (in fact, theIteratorPlusobject itself).For example, let's say you have an
Enumeration<String>and you want to loop over it with the for-each syntax. You could write:final Enumeration<String> en = ...; for (final String s : new IteratorPlus(en)) // do something with the stringThe same technique works with
Iterator.- Author:
- Curtis Rueden
-
-
Constructor Summary
Constructors Constructor Description IteratorPlus(Iterable<E> iterable)IteratorPlus(Enumeration<E> enumeration)IteratorPlus(Iterator<E> iterator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasMoreElements()booleanhasNext()Iterator<E>iterator()Enext()EnextElement()voidremove()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Method Detail
-
hasMoreElements
public boolean hasMoreElements()
- Specified by:
hasMoreElementsin interfaceEnumeration<E>
-
nextElement
public E nextElement()
- Specified by:
nextElementin interfaceEnumeration<E>
-
-