Is there an equivalent of Python's itertools for Java? [closed]
-
20-09-2019 - |
Question
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".
OTHER TIPS
I'm actually making a port of itertools to java: it's called neoitertools
Any feedback appreciated as it still in beta. Missing the "product" function yet, and some intensive tests.
Cartesian product is available here: http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Sets.html#cartesianProduct%28java.util.Set...%29
Here you find something that might cover your combinatorial needs bundled in a library:
I'm just throwing this out there, but shouldn't it be possible to use Python's itertools implementation directly from Java using Jython? Is it a C-based api?
[one Google later]
itertools (Jython API documentation)
Actually, the neoitertools project listed above looks very promising, it appears to be in [very] active development (according to Google code) and looks to be a complete implemetation of the itertools functionality, plus it's available via Maven.
Just my 2 pence.
Few years later, combinatorics seems to fit your needs. Taken from the readme:
Simple permutations
Permutations with repetitions
Simple combinations
Combinations with repetitions
Subsets
Integer Partitions
List Partitions
Integer Compositions