Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

permutations/combinatorics library for java? [closed]

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.

like image 555
Paul Sanwald Avatar asked Aug 17 '12 21:08

Paul Sanwald


1 Answers

There's the PermutationIterator class in the Apache Commons Collection library version 4. It accepts a generic Collection and provides an Iterator that iterates over all permutations of the elements in the Collection (each call to next() on the Iterator provides an ordered List).

I just realised version 4 of the Collection library was only released on 2013-11-27. Version 3 doesn't provide a utility for permutations. V4 "represents a major revamp of collections by supporting new language features introduced with Java 1.5, mainly support for generics."

like image 87
Oliver Coleman Avatar answered Oct 04 '22 04:10

Oliver Coleman