Class CounterIterator<T>
java.lang.Object
fr.lirmm.graphik.util.stream.AbstractCloseableIterator<T>
fr.lirmm.graphik.util.stream.CounterIterator<T>
- Type Parameters:
T- type of elements of the iterator
- All Implemented Interfaces:
CloseableIterator<T>, Closeable, AutoCloseable
Counts the number of elements read from a closeable iterator.
- Author:
- Clément Sipieter (INRIA) <clement@6pi.fr>
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a counter around the provided iterator. -
Method Summary
Methods inherited from class AbstractCloseableIterator
finalize
-
Constructor Details
-
CounterIterator
Creates a counter around the provided iterator.- Parameters:
it- the iterator to wrap
-
-
Method Details
-
getCptValue
public int getCptValue()Returns the number of elements returned so far.- Returns:
- the current element count
-
hasNext
Description copied from interface:CloseableIteratorReturns whether another element is available.- Returns:
- true if another element can be read
- Throws:
IteratorException- if the iteration fails
-
next
Description copied from interface:CloseableIteratorReturns the next element.- Returns:
- the next element
- Throws:
IteratorException- if the iteration fails
-
close
public void close()
-