jsr166z.forkjoin
Class ParallelIntArray.WithFilter

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

public abstract static class ParallelIntArray.WithFilter
extends ParallelIntArray.WithIntMapping

A restriction of parallel array operations to apply only to elements for which a selector returns true


Method Summary
 int any()
          Returns some element matching bound and filter constraints
 void apply({int=>void} procedure)
          Applies the given procedure
 int indexOfMax()
          Returns the index corresponding to the greatest element or -1 if empty, assuming that all elements are Comparables
 int indexOfMax({int,int=>int} comparator)
          Returns the index corresponding to the greatest element, or -1 if empty
 int indexOfMin()
          Returns the index corresponding to the least element or -1 if empty, assuming that all elements are Comparables
 int indexOfMin({int,int=>int} comparator)
          Returns the index corresponding to the least element or -1 if empty
 int max()
          Returns the maximum element, or Integer.MIN_VALUE if empty assuming that all elements are Comparables
 int max({int,int=>int} comparator)
          Returns the maximum element, or Integer.MIN_VALUE if empty
 int min()
          Returns the minimum element, or Integer.MAX_VALUE if empty, assuming that all elements are Comparables
 int min({int,int=>int} comparator)
          Returns the minimum element, or Integer.MAX_VALUE if empty
abstract  ParallelIntArray newArray()
          Returns a new ParallelArray holding elements
 void randomFill()
          Sets each element to a uniform random value having the same properties as Random.nextInt()
 void randomFill(int bound)
          Sets each element to a uniform random value having the same properties as Random.nextInt(int)
 int reduce({int,int=>int} reducer, int base)
          Returns reduction of elements
 void replaceWithCombination(int[] other, {int,int=>int} combiner)
          Replaces elements with results of applying combine(thisElement, otherElement)
 void replaceWithCombination(ParallelIntArray other, {int,int=>int} combiner)
          Replaces elements with results of applying combine(thisElement, otherElement)
 void replaceWithGeneratedValue({=>int} generator)
          Replaces elements with results of applying the given generator.
 void replaceWithMappedIndex({int=>int} mapper)
          Replaces elements with the results of applying the given mapper to their indices
 void replaceWithTransform({int=>int} mapper)
          Replaces elements with the results of applying the given mapper to their current values.
 void replaceWithValue(int value)
          Replaces elements with the given value.
 int sum()
          Returns the sum of elements
abstract  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.
abstract  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.
abstract  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.
abstract
<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.WithIntMapping
anyIndex, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

apply

public void apply({int=>void} procedure)
Applies the given procedure

Overrides:
apply in class ParallelIntArray.WithIntMapping
Parameters:
procedure - the procedure

reduce

public int reduce({int,int=>int} reducer,
                  int base)
Returns reduction of elements

Overrides:
reduce in class ParallelIntArray.WithIntMapping
Parameters:
reducer - the reducer
base - the result for an empty array
Returns:
reduction

sum

public int sum()
Returns the sum of elements

Overrides:
sum in class ParallelIntArray.WithIntMapping
Returns:
the sum of elements

min

public int min({int,int=>int} comparator)
Returns the minimum element, or Integer.MAX_VALUE if empty

Overrides:
min in class ParallelIntArray.WithIntMapping
Parameters:
comparator - the comparator
Returns:
minimum element, or Integer.MAX_VALUE if empty

min

public int min()
Returns the minimum element, or Integer.MAX_VALUE if empty, assuming that all elements are Comparables

Overrides:
min in class ParallelIntArray.WithIntMapping
Returns:
minimum element, or Integer.MAX_VALUE if empty

max

public int max({int,int=>int} comparator)
Returns the maximum element, or Integer.MIN_VALUE if empty

Overrides:
max in class ParallelIntArray.WithIntMapping
Parameters:
comparator - the comparator
Returns:
maximum element, or Integer.MIN_VALUE if empty

max

public int max()
Returns the maximum element, or Integer.MIN_VALUE if empty assuming that all elements are Comparables

Overrides:
max in class ParallelIntArray.WithIntMapping
Returns:
maximum element, or Integer.MIN_VALUE if empty

indexOfMin

public int indexOfMin({int,int=>int} comparator)
Returns the index corresponding to the least element or -1 if empty

Overrides:
indexOfMin in class ParallelIntArray.WithIntMapping
Parameters:
comparator - the comparator
Returns:
the index of least element or -1 if empty.

indexOfMax

public int indexOfMax({int,int=>int} comparator)
Returns the index corresponding to the greatest element, or -1 if empty

Overrides:
indexOfMax in class ParallelIntArray.WithIntMapping
Parameters:
comparator - the comparator
Returns:
the index of greatest element or -1 if empty.

indexOfMin

public int indexOfMin()
Returns the index corresponding to the least element or -1 if empty, assuming that all elements are Comparables

Overrides:
indexOfMin in class ParallelIntArray.WithIntMapping
Returns:
the index of least element or -1 if empty.
Throws:
java.lang.ClassCastException - if any element is not Comparable.

indexOfMax

public int indexOfMax()
Returns the index corresponding to the greatest element or -1 if empty, assuming that all elements are Comparables

Overrides:
indexOfMax in class ParallelIntArray.WithIntMapping
Returns:
the index of greatest element or -1 if empty.
Throws:
java.lang.ClassCastException - if any element is not Comparable.

newArray

public abstract ParallelIntArray newArray()
Returns a new ParallelArray holding elements

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

replaceWithTransform

public void replaceWithTransform({int=>int} mapper)
Replaces elements with the results of applying the given mapper to their current values.

Parameters:
mapper - the mapper

replaceWithMappedIndex

public void replaceWithMappedIndex({int=>int} mapper)
Replaces elements with the results of applying the given mapper to their indices

Parameters:
mapper - the mapper

replaceWithGeneratedValue

public void replaceWithGeneratedValue({=>int} generator)
Replaces elements with results of applying the given generator.

Parameters:
generator - the generator

randomFill

public void randomFill()
Sets each element to a uniform random value having the same properties as Random.nextInt()


randomFill

public void randomFill(int bound)
Sets each element to a uniform random value having the same properties as Random.nextInt(int)

Parameters:
bound - the upper bound of each random value
Throws:
java.lang.IllegalArgumentException - if bound less than or equal to zero

replaceWithValue

public void replaceWithValue(int value)
Replaces elements with the given value.

Parameters:
value - the value

replaceWithCombination

public void replaceWithCombination(ParallelIntArray other,
                                   {int,int=>int} combiner)
Replaces elements with results of applying combine(thisElement, otherElement)

Parameters:
other - the other array
combiner - the combiner
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other array has fewer than upperBound elements.

replaceWithCombination

public void replaceWithCombination(int[] other,
                                   {int,int=>int} combiner)
Replaces elements with results of applying combine(thisElement, otherElement)

Parameters:
other - the other array
combiner - the combiner
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other array has fewer than upperBound elements.

any

public int any()
Returns some element matching bound and filter constraints

Specified by:
any in class ParallelIntArray.WithIntMapping
Returns:
matching element
Throws:
java.util.NoSuchElementException - if empty

withMapping

public abstract <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.

Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public abstract 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.

Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public abstract 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.

Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public abstract 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.

Parameters:
mapper - the mapper
Returns:
operation prefix