permutations/combinatorics library for java?

Paul Sanwald picture Paul Sanwald · Aug 17, 2012 · Viewed 12.4k times · Source

I am looking for a library for java that will generate all possible order permutations of a set. The only library I can find is combinatoricslib on google code. I find it very hard to believe this is the only java library that does this, and am quite frankly very surprised by this.

Is there anything in the JDK, or apache commons math, or another library, that provides this same functionality?

I am happy to use combinatoricslib, I just can't believe that's the only option, other than writing the algorithm myself, which admittedly is not that difficult, but neither is .isBlankOrNull(), and apache commons includes that.

Answer

Cratylus picture Cratylus · Aug 17, 2012

Have you checked Guava? It seems to offer permutations in Collections2

Class Collections2
permutations(Collection elements)
Returns a Collection of all the permutations of the specified Collection.