Skip to content

Java 8 combinatorics-related streams and other utilities

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
license-header.txt
Notifications You must be signed in to change notification settings

brightcoder/streamplify

 
 

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 etc.
  • 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!

About

Java 8 combinatorics-related streams and other utilities

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
license-header.txt

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 73.5%
  • Groovy 26.0%
  • Other 0.5%