jsr166z.forkjoin
Class ParallelArray.WithFilter<T>

java.lang.Object
  extended by jsr166z.forkjoin.ParallelArray.WithMapping<T,T>
      extended by jsr166z.forkjoin.ParallelArray.WithFilter<T>
Direct Known Subclasses:
ParallelArray.WithBounds
Enclosing class:
ParallelArray<T>

public abstract static class ParallelArray.WithFilter<T>
extends ParallelArray.WithMapping<T,T>

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


Method Summary
abstract  T any()
          Returns some element matching bound and filter constraints, or null if none.
 void apply({T=>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(java.util.Comparator<? super T> 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(java.util.Comparator<? super T> comparator)
          Returns the index corresponding to the least element or -1 if empty
 T max()
          Returns the maximum element, or null if empty assuming that all elements are Comparables
 T max(java.util.Comparator<? super T> comparator)
          Returns the maximum element, or null if empty
 T min()
          Returns the minimum element, or null if empty, assuming that all elements are Comparables
 T min(java.util.Comparator<? super T> comparator)
          Returns the minimum element, or null if empty
abstract  ParallelArray<T> newArray()
          Returns a new ParallelArray holding elements
abstract  ParallelArray<T> newArray(java.lang.Class<? super T> elementType)
          Returns a new ParallelArray with the given element type holding elements
 T reduce({T,T=>T} reducer, T base)
          Returns reduction of elements
 void replaceWithCombination(ParallelArray<? extends T> other, {T,T=>T} combiner)
          Replaces elements with results of applying combine(thisElement, otherElement)
 void replaceWithCombination(T[] other, {T,T=>T} combiner)
          Replaces elements with results of applying combine(thisElement, otherElement)
 void replaceWithGeneratedValue({=>T} generator)
          Replaces elements with results of applying the given generator.
 void replaceWithMappedIndex({int=>T} mapper)
          Replaces elements with the results of applying the given mapper to their indices
 void replaceWithTransform({T=>T} mapper)
          Replaces elements with the results of applying the given mapper to their current values.
 void replaceWithValue(T value)
          Replaces elements with the given value.
abstract  ParallelArray.WithDoubleMapping<T> withMapping({T=>double} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
abstract  ParallelArray.WithIntMapping<T> withMapping({T=>int} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
abstract  ParallelArray.WithLongMapping<T> withMapping({T=>long} mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
abstract
<U> ParallelArray.WithMapping<T,U>
withMapping({T=>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.ParallelArray.WithMapping
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({T=>void} procedure)
Applies the given procedure

Overrides:
apply in class ParallelArray.WithMapping<T,T>
Parameters:
procedure - the procedure

reduce

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

Overrides:
reduce in class ParallelArray.WithMapping<T,T>
Parameters:
reducer - the reducer
base - the result for an empty array
Returns:
reduction

any

public abstract T any()
Returns some element matching bound and filter constraints, or null if none.

Specified by:
any in class ParallelArray.WithMapping<T,T>
Returns:
matching element, or null if none.

min

public T min(java.util.Comparator<? super T> comparator)
Returns the minimum element, or null if empty

Overrides:
min in class ParallelArray.WithMapping<T,T>
Parameters:
comparator - the comparator
Returns:
minimum element, or null if empty

min

public T min()
Returns the minimum element, or null if empty, assuming that all elements are Comparables

Overrides:
min in class ParallelArray.WithMapping<T,T>
Returns:
minimum element, or null if empty
Throws:
java.lang.ClassCastException - if any element is not Comparable.

max

public T max(java.util.Comparator<? super T> comparator)
Returns the maximum element, or null if empty

Overrides:
max in class ParallelArray.WithMapping<T,T>
Parameters:
comparator - the comparator
Returns:
maximum element, or null if empty

max

public T max()
Returns the maximum element, or null if empty assuming that all elements are Comparables

Overrides:
max in class ParallelArray.WithMapping<T,T>
Returns:
maximum element, or null if empty
Throws:
java.lang.ClassCastException - if any element is not Comparable.

indexOfMin

public int indexOfMin(java.util.Comparator<? super T> comparator)
Returns the index corresponding to the least element or -1 if empty

Overrides:
indexOfMin in class ParallelArray.WithMapping<T,T>
Parameters:
comparator - the comparator
Returns:
the index of least element or -1 if empty.

indexOfMax

public int indexOfMax(java.util.Comparator<? super T> comparator)
Returns the index corresponding to the greatest element, or -1 if empty

Overrides:
indexOfMax in class ParallelArray.WithMapping<T,T>
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 ParallelArray.WithMapping<T,T>
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 ParallelArray.WithMapping<T,T>
Returns:
the index of greatest element or -1 if empty.
Throws:
java.lang.ClassCastException - if any element is not Comparable.

newArray

public abstract ParallelArray<T> newArray()
Returns a new ParallelArray holding elements

Specified by:
newArray in class ParallelArray.WithMapping<T,T>
Returns:
a new ParallelArray holding elements

newArray

public abstract ParallelArray<T> newArray(java.lang.Class<? super T> elementType)
Returns a new ParallelArray with the given element type holding elements

Specified by:
newArray in class ParallelArray.WithMapping<T,T>
Parameters:
elementType - the type of the elements
Returns:
a new ParallelArray holding elements

replaceWithTransform

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

Parameters:
mapper - the mapper

replaceWithMappedIndex

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

Parameters:
mapper - the mapper

replaceWithGeneratedValue

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

Parameters:
generator - the generator

replaceWithValue

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

Parameters:
value - the value

replaceWithCombination

public void replaceWithCombination(ParallelArray<? extends T> other,
                                   {T,T=>T} 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(T[] other,
                                   {T,T=>T} 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.

withMapping

public abstract <U> ParallelArray.WithMapping<T,U> withMapping({T=>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 ParallelArray.WithMapping<T,T>
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public abstract ParallelArray.WithDoubleMapping<T> withMapping({T=>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 ParallelArray.WithLongMapping<T> withMapping({T=>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 ParallelArray.WithIntMapping<T> withMapping({T=>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