Package com.complexible.common.base
Interface CloseableIterator<T>
- All Superinterfaces:
AutoCloseable,Iterator<T>
- All Known Subinterfaces:
BindingSetIterator,BooleanQueryResult,GraphQueryResult,MarkResetIterator<T>,PathQueryResult,PeekingSkippingIterator<T>,QueryResult<T>,ResettableIterator<T>,RestrictedMarkResetIterator<T>,SelectQueryResult,SkippingIterator<T>,StatementIterator
- All Known Implementing Classes:
AbstractSkippingIterator,AsyncGraphQueryResult,AsyncSelectQueryResult,CloseableIterator.AbstractCloseableIterator,CloseableIterator.DelegatingCloseableIterator,CloseableIterator.EmptyCloseableIterator,DelegatingSkippingIterator,GraphQueryResultIterator,HandlerBackedIterator,IOBindingSetIterator,IteratorAsBooleanQueryResult,IteratorAsGraphQueryResult,IteratorAsPathQueryResult,IteratorAsQueryResult,IteratorAsTupleQueryResult,MarkResetSkippingIterator,MultiStatementIterator,PathsAsTupleQueryResult,SpoolingMarkResetIterator,TupleQueryResultIterator,TuplesAsPathQueryResult
- Since:
- 4.0
- Version:
- 7.4.2
- Author:
- Michael Grove
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static voidcloseQuietly(Iterator<?> theIterator) static <T,A, R> R collect(CloseableIterator<T> theIter, Collector<T, A, R> theCollector) Collect the contents of the iterator.static <I> CloseableIterator<I> concat(CloseableIterator<I> theFirst, CloseableIterator<I> theSecond) static <T> CloseableIterator<T> concat(Iterable<? extends CloseableIterator<T>> theIters) static <T> CloseableIterator<T> concat(Iterator<? extends CloseableIterator<T>> inputs) static <T> CloseableIterator<T> empty()static <T> CloseableIterator<T> filter(CloseableIterator<T> theIter, Predicate<T> thePredicate) static <T> Optional<T> first(CloseableIterator<T> theIter) Get the first element in the iterator.static <I,O> CloseableIterator <O> flatMap(CloseableIterator<I> theIterator, Function<? super I, ? extends CloseableIterator<O>> theFunction) static booleanisEmpty(CloseableIterator<?> theIterator) static <T> CloseableIterator<T> limit(CloseableIterator<T> theIter, long theLimit) static <I,O> CloseableIterator <O> map(CloseableIterator<I> theIterator, Function<? super I, O> theFunction) static <T> CloseableIterator<T> of(T... theElements) static <T> CloseableIterator<T> offset(CloseableIterator<T> theIter, long theOffset) static <T> CloseableIterator<T> onClose(CloseableIterator<T> theIter, Runnable theRunnable) static <T> CloseableIterator<T> singleton(T theElem) static <T> longsize(CloseableIterator<T> theIter) Return the number of elements in the iterator.static <T> CloseableIterator<T> toCloseable(Iterator<? extends T> theIterator) static <T> CloseableIterator<T> toCloseable(Iterator<? extends T> theIterator, Runnable theOnClose) static <T> CloseableIterator<T> toCloseable(Stream<T> theStream) static <T> List<T> toList(CloseableIterator<T> theIter) Collect the contents of the iterator as aList.static <T> Set<T> toSet(CloseableIterator<T> theIter) Collect the contents of the iterator as aSet.static <In,Out> CloseableIterator <Out> transform(CloseableIterator<In> theIter, Function<In, Out> theFunction) Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
RuntimeException
-
onClose
@MustBeClosed static <T> CloseableIterator<T> onClose(CloseableIterator<T> theIter, Runnable theRunnable) -
closeQuietly
-
empty
-
singleton
-
of
-
concat
@MustBeClosed static <T> CloseableIterator<T> concat(Iterable<? extends CloseableIterator<T>> theIters) -
concat
-
first
Get the first element in the iterator. The iterator is closed after collection.- Parameters:
theIter- the iterator- Returns:
- the first element in the iterator, or empty if none.
-
toSet
Collect the contents of the iterator as aSet. The iterator is closed after collection.- Parameters:
theIter- the iterator- Returns:
- the contents of the iterator as a Set.
-
toList
Collect the contents of the iterator as aList. The iterator is closed after collection.- Parameters:
theIter- the iterator- Returns:
- the contents of the iterator as a list.
-
collect
Collect the contents of the iterator. The iterator is closed after collection.- Parameters:
theIter- the iterator whose contents should be collectedtheCollector- the colector- Returns:
- the collected object
-
size
Return the number of elements in the iterator. The iterator is closed after collection.- Parameters:
theIter- the iterator- Returns:
- the number of elements in the Iterator
-
offset
-
limit
-
filter
@MustBeClosed static <T> CloseableIterator<T> filter(CloseableIterator<T> theIter, Predicate<T> thePredicate) -
transform
@MustBeClosed static <In,Out> CloseableIterator<Out> transform(CloseableIterator<In> theIter, Function<In, Out> theFunction) -
toCloseable
-
toCloseable
-
toCloseable
@MustBeClosed static <T> CloseableIterator<T> toCloseable(Iterator<? extends T> theIterator, Runnable theOnClose) -
isEmpty
-
map
static <I,O> CloseableIterator<O> map(CloseableIterator<I> theIterator, Function<? super I, O> theFunction) -
flatMap
static <I,O> CloseableIterator<O> flatMap(CloseableIterator<I> theIterator, Function<? super I, ? extends CloseableIterator<O>> theFunction) -
concat
static <I> CloseableIterator<I> concat(CloseableIterator<I> theFirst, CloseableIterator<I> theSecond)
-