guava icon indicating copy to clipboard operation
guava copied to clipboard

Add `Ints.shuffle()`

Open leventov opened this issue 6 years ago • 6 comments

There are very similar arguments applying to this question as to #502 (Add Ints.reverse()), the difference is that shuffle algorithm is a bit less trivial than reverse().

leventov avatar Aug 10 '19 07:08 leventov

I don't see a lot of evidence of people needing to shuffle arrays of ints in Google's codebase. Do you see a lot of use of Collections.shuffle({Ints,Arrays}.asList(...)) in your codebase?

netdpb avatar Aug 12 '19 15:08 netdpb

I find myself visiting this SO question to copy the code from time to time. This definitely happened more than three times. Avoiding Collections.shuffle(Ints.asList(a)) is a performance habit.

leventov avatar Aug 12 '19 17:08 leventov

See ArrayUtils#shuffle(int[]) in Apache Commons Lang3.

ben-manes avatar Aug 13 '19 03:08 ben-manes

Can I implement this feature?

Stupremee avatar Oct 17 '19 16:10 Stupremee

@leventov Hello! I would like to take on this task as a first challenge. Can I start working on it?

sagada avatar Oct 14 '23 13:10 sagada

Hi @Stupremee and @sagada. Thanks for your interest in contributing!

Please take a look at How to Contribute. We haven't gotten to the point of deciding that this feature is worth adding to Guava, so we're definitely not ready to implement it. And often it's more work for us to accept a PR than it is for us to implement it ourselves. I'm afraid this is likely one of those cases.

netdpb avatar Oct 18 '23 20:10 netdpb