Class ProgressIterator<E>
java.lang.Object
uk.ac.manchester.spinnaker.utils.progress.ProgressIterator<E>
- Type Parameters:
- E- Type of Element to be iterated over.
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Iterator<E>
An 
Iterator wrapper with and an attached ProgressBar. Mainly
 designed as a support class for ProgressIterable.
 
 As items are obtained by calling next() the ProgressBar is updated.
 When hasNext() returns false the ProgressBar is closed resulting in
 the duration to be written out.
- Author:
- Christian-B
- 
Constructor SummaryConstructorsConstructorDescriptionProgressIterator(Collection<E> outer, String description, PrintStream output) Creates a newProgressIterableand a bar on the output stream.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes the underlyingProgressBar.booleanhasNext()Returns true if the iteration has more elements.next()Returns the next element in the iteration, and updates the ProgressBar.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining, remove
- 
Constructor Details- 
ProgressIteratorCreates a newProgressIterableand a bar on the output stream.- Parameters:
- outer- A Collection to supply a size and and Iterable.
- description- A text description to add at the start and when reporting duration.
- output- The Stream to write output too. For example- System.out
 
 
- 
- 
Method Details- 
hasNextpublic boolean hasNext()Returns true if the iteration has more elements. (In other words, returns true ifnext()would return an element rather than throwing an exception.)When hasNext()returns false the ProgressBar is closed.
- 
nextReturns the next element in the iteration, and updates the ProgressBar.- Specified by:
- nextin interface- Iterator<E>
- Returns:
- The next element from the underlying iterator.
- Throws:
- NoSuchElementException- if the iteration has no more elements
- IllegalStateException- is the Iterator and therefore the ProgressBar have been closed.
 
- 
closepublic void close()Closes the underlyingProgressBar.Note: As hasNext() == falseautomatically calls close there is no need to call this method unless you break out of the iterator early.If the bar is already closed then invoking this method has no effect. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
 
-