I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.
The best way of describing what I want would be "itertools for Java".
I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.
The best way of describing what I want would be "itertools for Java".
itertools
does much more than just combinations and permutations, so (while it would surely be nice to have all of itertools
when coding Java;-) you can get away with much less.
For example, for permutations, see here; for combinations, here (both classes are from the same author).
Cartesian product is available here: http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Sets.html#cartesianProduct%28java.util.Set...%29