https://github.com/robtimus/iterator-utils
Provides classes and interfaces to help implement iterators
https://github.com/robtimus/iterator-utils
iterators java
Last synced: 4 months ago
JSON representation
Provides classes and interfaces to help implement iterators
- Host: GitHub
- URL: https://github.com/robtimus/iterator-utils
- Owner: robtimus
- License: apache-2.0
- Created: 2022-12-29T18:45:46.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-25T18:57:05.000Z (over 1 year ago)
- Last Synced: 2024-11-17T06:41:41.567Z (6 months ago)
- Topics: iterators, java
- Language: Java
- Homepage: https://robtimus.github.io/iterator-utils/
- Size: 427 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# iterator-utils
[](https://github.com/robtimus/iterator-utils/actions/workflows/build.yml)
[](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aiterator-utils)
[](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aiterator-utils)
[](https://snyk.io/test/github/robtimus/iterator-utils)Provides classes and interfaces to help implement iterators. Below are some examples; for a full list, see the [API](https://robtimus.github.io/iterator-utils/apidocs/).
## LookaheadIterator
Class [LookaheadIterator](https://robtimus.github.io/iterator-utils/apidocs/com/github/robtimus/util/iterator/LookaheadIterator.html) is a base class that lets you easily implement iterators that need to calculate the next value in order to let `hasNext()` return whether or not there is a next value.
## StreamLikeIterator
Interface [StreamLikeIterator](https://robtimus.github.io/iterator-utils/apidocs/com/github/robtimus/util/iterator/StreamLikeIterator.html) extends `Iterator` to add several `Stream` operations. Unlike streams, instances of `StreamLikeIterator` support removal if a) the original iterator does, and b) no intermediate step removes support for removal (e.g., `flatMap`).
## IteratorUtils
Class [IteratorUtils](https://robtimus.github.io/iterator-utils/apidocs/com/github/robtimus/util/iterator/IteratorUtils.html) provides several utility methods. These include:
* `singletonIterator` to create an (unmodifiable) iterator containing only a single element.
* `unmodifiableIterator` to create an unmodifiable wrapper around an iterator.
* methods to wrap an existing iterator to add functionality of `Stream`. This allows single operations to be used without having to use `StreamLikeIterator`.
* methods to create a `Stream` for an iterator.
* methods to create a single iterator backed by several other iterators or iterables.