Skip to content

dabla/parallel-iterable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallel-Iterable

Build Status

Transform or filter collections concurrently

Just use the ParallelIterable like you would use the FluentIterable in Guava. The transformation or filtering of each element will be done concurrently behind the scenes.

Code sample

package be.dabla.parallel.iterable;

import static com.google.common.collect.Lists.newArrayList;
import static java.math.BigInteger.ONE;
import static java.math.BigInteger.ZERO;

import java.math.BigInteger;
import java.util.List;

import com.google.common.base.Function;

public class Sample {
    
    public List<BigInteger> incrementAllByOne() {
        return ParallelIterable.from(newArrayList(ZERO, ONE))
                        	   .transform(addOne())
                        	   .toList();
    }
    
    private Function<BigInteger, BigInteger> addOne() {
        return new Function<BigInteger, BigInteger>() {
            public BigInteger apply(BigInteger input) {
                return input.add(ONE);
            }
        };
    }
}

How to use in your project

Example for Maven:

<dependency>
    <groupId>be.dabla</groupId>
    <artifactId>parallel-iterable</artifactId>
    <version>1.4</version>
</dependency>

Maven artifact can be found at https://oss.sonatype.org/content/repositories/public/be/dabla/parallel-iterable