Skip to content

Document that Multisets.intersection performs better with the smaller… - #8898

Open
marconi-prog wants to merge 3 commits into
google:masterfrom
DevNeto07:fix-2237-multisets-intersection-docs
Open

marconi-prog wants to merge 3 commits into
google:masterfrom
DevNeto07:fix-2237-multisets-intersection-docs

Conversation

@marconi-prog

Copy link
Copy Markdown

Fixes #2237

Adds a note to Multisets.intersection, similar to the one in Sets.intersection: the returned view iterates over multiset1 and looks up each element in multiset2, so passing the smaller multiset first performs better.

I didn't add a note to union: its iterator goes over both multisets and does one lookup per element either way, so neither argument order is structurally cheaper.

Javadoc only, no behavior change.

I used an AI assistant to help analyze the issue and draft this change; I reviewed it myself.

marconi-prog and others added 3 commits November 23, 2026 14:54
Describe work in terms of distinct elements and count lookup costs instead of promising better performance from the smaller total multiset size.

Refs google#2237
Co-authored-by: Sérgio Luiz Santos Neto <sneto.dev@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q6GRjomh5J9vHFVXMDHDWD

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multisets intersection and union: Note performance effect of argument order in javadoc

2 participants