Skip to content

Navigation Menu

Sign in
Sign up

Add Streams.forEachWithIndex - #8457

Open
sri-adarsh-kumar wants to merge 2 commits into
google:master from
sri-adarsh-kumar:feature/2913
Open

Add Streams.forEachWithIndex #8457
sri-adarsh-kumar wants to merge 2 commits into
google:master from
sri-adarsh-kumar:feature/2913

Conversation

@sri-adarsh-kumar

@sri-adarsh-kumar sri-adarsh-kumar commented Jun 1, 2026

Copy link
Copy Markdown

Summary

  • add Streams.forEachWithIndex(Stream, ObjLongConsumer) as a terminal counterpart to mapWithIndex
  • delegate through mapWithIndex so indexed traversal stays on one code path in both JRE and Android Streams
  • add StreamsTest coverage for sized, unsized, null-element, null-check, and parallel index-correctness cases

Context

Intentional Non-Goals

  • no primitive overloads in this PR
  • no stronger parallel ordering guarantee than correct element-to-index correspondence
  • no implicit closing of the source stream

Test Plan

  • Ran ./mvnw -pl guava-tests -Dtest=StreamsTest -DfailIfNoTests=false -Dmaven.javadoc.skip test

GenAI Usage

  • I used GenAI assistance while drafting parts of the implementation and tests.
  • I manually reviewed the final API shape, semantics, and test coverage before opening the PR.

google-cla Bot commented Jun 1, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /