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`

public interface CloseableIterator<T> extends Iterator<T>, AutoCloseable

An `Iterator` which can be `closed`.

Since:
  4.0
Version:
  7.4.2
Author:
  Michael Grove

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `CloseableIterator.AbstractCloseableIterator<T>`
  `static class`
  `CloseableIterator.DelegatingCloseableIterator<T>`
  `static class`
  `CloseableIterator.EmptyCloseableIterator<T>`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `static void`
  `closeQuietly(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 boolean`
  `isEmpty(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> long`
  `size(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 a `List`.
  `static <T> Set<T>`
  `toSet(CloseableIterator<T> theIter)`
  Collect the contents of the iterator as a `Set`.
  `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

    void close() throws RuntimeException
    Specified by:
      `close` in interface `AutoCloseable`
    Throws:
      `RuntimeException`

  - ### onClose

    @MustBeClosed static <T> CloseableIterator<T> onClose(CloseableIterator<T> theIter, Runnable theRunnable)

  - ### closeQuietly

    static void closeQuietly(Iterator<?> theIterator)

  - ### empty

    static <T> CloseableIterator<T> empty()

  - ### singleton

    @MustBeClosed static <T> CloseableIterator<T> singleton(T theElem)

  - ### of

    @MustBeClosed static <T> CloseableIterator<T> of(T... theElements)

  - ### concat

    @MustBeClosed static <T> CloseableIterator<T> concat(Iterable<? extends CloseableIterator<T>> theIters)

  - ### concat

    static <T> CloseableIterator<T> concat(Iterator<? extends CloseableIterator<T>> inputs)

  - ### first

    static <T> Optional<T> first(CloseableIterator<T> theIter)
    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

    static <T> Set<T> toSet(CloseableIterator<T> theIter)
    Collect the contents of the iterator as a `Set`. The iterator is closed after collection.
    Parameters:
      `theIter` - the iterator
    Returns:
      the contents of the iterator as a Set.

  - ### toList

    static <T> List<T> toList(CloseableIterator<T> theIter)
    Collect the contents of the iterator as a `List`. The iterator is closed after collection.
    Parameters:
      `theIter` - the iterator
    Returns:
      the contents of the iterator as a list.

  - ### collect

    static <T, A, R> R collect(CloseableIterator<T> theIter, Collector<T,A,R> theCollector)
    Collect the contents of the iterator. The iterator is closed after collection.
    Parameters:
      `theIter` - the iterator whose contents should be collected
      `theCollector` - the colector
    Returns:
      the collected object

  - ### size

    static <T> long size(CloseableIterator<T> theIter)
    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

    @MustBeClosed static <T> CloseableIterator<T> offset(CloseableIterator<T> theIter, long theOffset)

  - ### limit

    @MustBeClosed static <T> CloseableIterator<T> limit(CloseableIterator<T> theIter, long theLimit)

  - ### 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

    @MustBeClosed static <T> CloseableIterator<T> toCloseable(Stream<T> theStream)

  - ### toCloseable

    @MustBeClosed static <T> CloseableIterator<T> toCloseable(Iterator<? extends T> theIterator)

  - ### toCloseable

    @MustBeClosed static <T> CloseableIterator<T> toCloseable(Iterator<? extends T> theIterator, Runnable theOnClose)

  - ### isEmpty

    static boolean isEmpty(CloseableIterator<?> theIterator)

  - ### 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)