jsr166z.forkjoin
Class ParallelArray.WithBounds<T>

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

public static final class ParallelArray.WithBounds<T>
extends ParallelArray.WithFilter<T>

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


Method Summary
 T any()
          Returns some element matching bound constraints, or null if none.
 int anyIndex()
          Returns the index of some element matching bound filter constraints, or -1 if none.
<U,V> ParallelArray<V>
combine(ParallelArray<U> other, {T,U=>V} combiner)
          Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.
<U,V> ParallelArray<V>
combine(ParallelArray<U> other, {T,U=>V} combiner, java.lang.Class<? super V> elementType)
          Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.
<U,V> ParallelArray<V>
combine(U[] other, {T,U=>V} combiner)
          Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.
<U,V> ParallelArray<V>
combine(U[] other, {T,U=>V} combiner, java.lang.Class<? super V> elementType)
          Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.
 void cumulate({T,T=>T} reducer, T base)
          Replaces each element with the running cumulation of applying the given reducer.
 ParallelArray<T> newArray()
          Returns a new ParallelArray holding elements
 ParallelArray<T> newArray(java.lang.Class<? super T> elementType)
          Returns a new ParallelArray with the given element type holding elements
 T precumulate({T,T=>T} reducer, T base)
          Replaces each element with the cumulation of applying the given reducer to all previous values, and returns the total reduction.
 int size()
          Returns the number of elements within bounds
 void sort()
          Sorts the elements, assuming all elements are Comparable.
 void sort(java.util.Comparator<? super T> cmp)
          Sorts the elements.
 ParallelArray.WithFilter<T> withFilter({T=>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
 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.
 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.
 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.
<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.WithFilter
apply, indexOfMax, indexOfMax, indexOfMin, indexOfMin, max, max, min, min, reduce, replaceWithCombination, replaceWithCombination, replaceWithGeneratedValue, replaceWithMappedIndex, replaceWithTransform, replaceWithValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withFilter

public ParallelArray.WithFilter<T> withFilter({T=>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> 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.WithFilter<T>
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

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

Specified by:
withMapping in class ParallelArray.WithFilter<T>
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

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

Specified by:
withMapping in class ParallelArray.WithFilter<T>
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

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

Specified by:
withMapping in class ParallelArray.WithFilter<T>
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 ParallelArray.WithMapping<T,T>
Returns:
index of matching element, or -1 if none.

any

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

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

combine

public <U,V> ParallelArray<V> combine(U[] other,
                                      {T,U=>V} 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 <U,V> ParallelArray<V> combine(U[] other,
                                      {T,U=>V} combiner,
                                      java.lang.Class<? super V> elementType)
Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.

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

combine

public <U,V> ParallelArray<V> combine(ParallelArray<U> other,
                                      {T,U=>V} 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 <U,V> ParallelArray<V> combine(ParallelArray<U> other,
                                      {T,U=>V} combiner,
                                      java.lang.Class<? super V> elementType)
Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element.

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

newArray

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

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

newArray

public 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.WithFilter<T>
Parameters:
elementType - the type of the elements
Returns:
a new ParallelArray holding elements

size

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

Specified by:
size in class ParallelArray.WithMapping<T,T>
Returns:
the number of elements within bounds

cumulate

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

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

precumulate

public T precumulate({T,T=>T} reducer,
                     T 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

sort

public void sort(java.util.Comparator<? super T> cmp)
Sorts the elements. Unlike Arrays.sort, this sort does not guarantee that elements with equal keys maintain their relative position in the array.

Parameters:
cmp - the comparator to use

sort

public void sort()
Sorts the elements, assuming all elements are Comparable. Unlike Arrays.sort, this sort does not guarantee that elements with equal keys maintain their relative position in the array.

Throws:
java.lang.ClassCastException - if any element is not Comparable.