amaembo / streamex

Enhancing Java Stream API
Apache License 2.0
2.18k stars 249 forks source link

Correcting a comment in EntryStream.java #273

Closed kivanval closed 9 months ago

kivanval commented 9 months ago

in EntryStream.java, in the ofPairs() methods, there was an error in the formula for the size of the output EntryStream.

The ofPairs() methods by its nature calculate all possible combinations of list items (Actually, I don't really understand why it's not called ofCombinations()).

The formula for combinations is as follows: image

If we take our specific case, where r = 2, the formula will look like this: image

amaembo commented 9 months ago

Thank you, merged.

Actually, I don't really understand why it's not called ofCombinations()

Because it does not produce any combinations (with arbitrary r), but a partial case with r = 2. There's StreamEx#ofCombinations method that produces any combination vectors.

amaembo commented 9 months ago

By the way, there's the same problem in documentation in StreamEx.ofPairs methods.

kivanval commented 9 months ago

By the way, there's the same problem in documentation in StreamEx.ofPairs methods.

Can you change it yourself or do I have to make another pull request? :D For some reason I missed that StreamEx has such a method.