Interface CloseableIterator<T>

    • Method Detail

      • close

        void close()
            throws java.lang.RuntimeException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.RuntimeException
      • closeQuietly

        static void closeQuietly​(java.util.Iterator<?> theIterator)
      • first

        static <T> java.util.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> java.util.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> java.util.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,
                                             java.util.stream.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
      • toCloseable

        @MustBeClosed
        static <T> CloseableIterator<T> toCloseable​(java.util.stream.Stream<T> theStream)
      • toCloseable

        static <T> CloseableIterator<T> toCloseable​(java.util.Iterator<? extends T> theIterator)
      • toCloseable

        @MustBeClosed
        static <T> CloseableIterator<T> toCloseable​(java.util.Iterator<? extends T> theIterator,
                                                    java.lang.Runnable theOnClose)