Streamplify Save

Java 8 combinatorics-related streams and other utilities

Project README

PRs Welcome License Build Status

Streamplify

The goal of this library is to provide useful Java 8 streams and to assist you in building new streams that allow efficient parallel processing.

The utilities offered by Streamplify include:

  • combinatorics streams: permutations, combinations, Cartesian products, power sets, derangements, partial permutations.
  • classes that help you implement your own efficient parallel streams.

Example

The following code snippet uses a parallel permutation stream to find all solutions of the N-Queens problem for n = 10.

System.out.println(new Permutations(10)
        .parallelStream()
        .filter(perm -> {
            for(int i = 0; i < perm.length - 1; i++) {
                for(int j = i + 1; j < perm.length; j++) {
                    if(Math.abs(perm[j] - perm[i]) == j - i) return false;
                }
            }
            return true;
        })
        .map(perm -> IntStream.range(0, perm.length)
                .mapToObj(i -> "(" + (i + 1) + "," + (perm[i] + 1) + ")")
                .collect(Collectors.joining(", ")))
        .collect(Collectors.joining("\n")));

Before starting to use the library, take a look at the examples, read the documentation and consult the javadoc.

Streamplify is available in Maven Central and JCenter.

Contribute to this project!

We accept all types of contributions and we are very welcoming to first time contributors.

Read how to contribute and jump in!

Open Source Agenda is not affiliated with "Streamplify" Project. README Source: beryx/streamplify
Stars
40
Open Issues
0
Last Commit
5 years ago
Repository
License

Open Source Agenda Badge

Open Source Agenda Rating