Class CloseableIteratorAccumulator<E>
java.lang.Object
fr.lirmm.graphik.util.stream.AbstractCloseableIterator<E>
fr.lirmm.graphik.util.stream.CloseableIteratorAccumulator<E>
- Type Parameters:
E- the iterated element type
- All Implemented Interfaces:
CloseableIterator<E>, Closeable, AutoCloseable
This Iterator stores the items passed in a buffer memory.
- Author:
- Olivier Rodriguez
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an accumulator around the specified iterator. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Consume the iterator (iterate until the last element).getList()Returns a copy of the buffered elements.booleanhasNext()Returns whether another element is available.next()Returns the next element.E[]toArray()Returns the buffered elements as an array.Methods inherited from class AbstractCloseableIterator
finalize
-
Constructor Details
-
CloseableIteratorAccumulator
Creates an accumulator around the specified iterator.- Parameters:
it- the iterator to consume and buffer- Throws:
IteratorException- if testing the first element fails
-
-
Method Details
-
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() -
consumeAll
Consume the iterator (iterate until the last element).- Returns:
- this accumulator after the iterator has been exhausted
- Throws:
IteratorException- if the iteration fails
-
toArray
-
getList
-