jsr166z.forkjoin
Class ParallelIntArray.WithBounds

java.lang.Object
  extended by jsr166z.forkjoin.ParallelIntArray.WithIntMapping
      extended by jsr166z.forkjoin.ParallelIntArray.WithFilter
          extended by jsr166z.forkjoin.ParallelIntArray.WithBounds
Enclosing class:
ParallelIntArray

public static final class ParallelIntArray.WithBounds
extends ParallelIntArray.WithFilter

A restriction of parallel array operations to apply only within a given range of indices.


Method Summary
 int anyIndex()
          Returns the index of some element matching bound filter constraints, or -1 if none.
 ParallelIntArray combine(int[] other, {int,int=>int} combiner)
          Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.
 ParallelIntArray combine(ParallelIntArray other, {int,int=>int} combiner)
          Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.
 void cumulate({int,int=>int} reducer, int base)
          Replaces each element with the running cumulation of applying the given reducer.
 void cumulateSum()
          Replaces each element with the running sum
 ParallelIntArray newArray()
          Returns a new ParallelArray holding elements
 int precumulate({int,int=>int} reducer, int base)
          Replaces each element with the cumulation of applying the given reducer to all previous values, and returns the total reduction.
 int precumulateSum()
          Replaces each element with its prefix sum
 int size()
          Returns the number of elements within bounds
 void sort()
          Sorts the elements, using natural comparator
 void sort({int,int=>int} cmp)
          Sorts the elements.
 ParallelIntArray.WithFilter withFilter({int=>boolean} selector)
          Returns an operation prefix that causes a method to operate only on the elements of the array for which the given selector returns true
 ParallelIntArray.WithDoubleMapping withMapping({int=>double} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
 ParallelIntArray.WithIntMapping withMapping({int=>int} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
 ParallelIntArray.WithLongMapping withMapping({int=>long} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
<U> ParallelIntArray.WithMapping<U>
withMapping({int=>U} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
 
Methods inherited from class jsr166z.forkjoin.ParallelIntArray.WithFilter
any, apply, indexOfMax, indexOfMax, indexOfMin, indexOfMin, max, max, min, min, randomFill, randomFill, reduce, replaceWithCombination, replaceWithCombination, replaceWithGeneratedValue, replaceWithMappedIndex, replaceWithTransform, replaceWithValue, sum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withFilter

public ParallelIntArray.WithFilter withFilter({int=>boolean} selector)
Returns an operation prefix that causes a method to operate only on the elements of the array for which the given selector returns true

Parameters:
selector - the selector
Returns:
operation prefix

withMapping

public <U> ParallelIntArray.WithMapping<U> withMapping({int=>U} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelIntArray.WithFilter
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelIntArray.WithDoubleMapping withMapping({int=>double} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelIntArray.WithFilter
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelIntArray.WithLongMapping withMapping({int=>long} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelIntArray.WithFilter
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelIntArray.WithIntMapping withMapping({int=>int} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelIntArray.WithFilter
Parameters:
mapper - the mapper
Returns:
operation prefix

anyIndex

public int anyIndex()
Returns the index of some element matching bound filter constraints, or -1 if none.

Specified by:
anyIndex in class ParallelIntArray.WithIntMapping
Returns:
index of matching element, or -1 if none.

combine

public ParallelIntArray combine(int[] other,
                                {int,int=>int} combiner)
Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.

Parameters:
other - the other array
combiner - the combiner
Returns:
the array of mappings
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other array is shorter than this array.

combine

public ParallelIntArray combine(ParallelIntArray other,
                                {int,int=>int} combiner)
Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.

Parameters:
other - the other array
combiner - the combiner
Returns:
the array of mappings
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other array is shorter than this array.

size

public int size()
Returns the number of elements within bounds

Specified by:
size in class ParallelIntArray.WithIntMapping
Returns:
the number of elements within bounds

cumulate

public void cumulate({int,int=>int} reducer,
                     int base)
Replaces each element with the running cumulation of applying the given reducer.

Parameters:
reducer - the reducer
base - the result for an empty array

cumulateSum

public void cumulateSum()
Replaces each element with the running sum


precumulate

public int precumulate({int,int=>int} reducer,
                       int base)
Replaces each element with the cumulation of applying the given reducer to all previous values, and returns the total reduction.

Parameters:
reducer - the reducer
base - the result for an empty array
Returns:
the total reduction

precumulateSum

public int precumulateSum()
Replaces each element with its prefix sum

Returns:
the total sum

sort

public void sort({int,int=>int} cmp)
Sorts the elements.

Parameters:
cmp - the comparator to use

sort

public void sort()
Sorts the elements, using natural comparator


newArray

public ParallelIntArray newArray()
Description copied from class: ParallelIntArray.WithFilter
Returns a new ParallelArray holding elements

Specified by:
newArray in class ParallelIntArray.WithFilter
Returns:
a new ParallelArray holding elements