jsr166y.forkjoin
Class ParallelDoubleArray.WithBounds

java.lang.Object
  extended by jsr166y.forkjoin.ParallelDoubleArray.WithDoubleMapping
      extended by jsr166y.forkjoin.ParallelDoubleArray.WithFilter
          extended by jsr166y.forkjoin.ParallelDoubleArray.WithBounds
Enclosing class:
ParallelDoubleArray

public static final class ParallelDoubleArray.WithBounds
extends ParallelDoubleArray.WithFilter

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


Method Summary
 ParallelDoubleArray all()
          Returns a new ParallelDoubleArray holding elements
 ParallelDoubleArray allUniqueElements()
          Returns a new ParallelDoubleArray containing only unique elements (that is, without any duplicates).
 int anyIndex()
          Returns the index of some element matching bound and filter constraints, or -1 if none.
 int binarySearch(double target)
          Assuming this array is sorted, returns the index of an element equal to given target, or -1 if not present.
 int binarySearch(double target, Ops.DoubleComparator comparator)
          Assuming this array is sorted with respect to the given comparator, returns the index of an element equal to given target, or -1 if not present.
 ParallelDoubleArray combine(double[] other, Ops.DoubleReducer combiner)
          Returns a ParallelDoubleArray containing results of applying combine(thisElement, otherElement) for each element.
<U,V> ParallelDoubleArray
combine(ParallelDoubleArray.WithBounds other, Ops.DoubleReducer combiner)
          Returns a ParallelDoubleArray containing results of applying combine(thisElement, otherElement) for each element.
 ParallelDoubleArray combine(ParallelDoubleArray other, Ops.DoubleReducer combiner)
          Returns a ParallelDoubleArray containing results of applying combine(thisElement, otherElement) for each element.
 void cumulate(Ops.DoubleReducer reducer, double base)
          Replaces each element with the running cumulation of applying the given reducer.
 void cumulateSum()
          Replaces each element with the running sum
 int indexOf(double target)
          Returns the index of some element equal to given target, or -1 if not present
 ParallelDoubleArray.WithFilter orFilter(Ops.DoublePredicate selector)
          Returns an operation prefix that causes a method to operate only on elements for which the current selector (if present) or the given selector returns true
 double precumulate(Ops.DoubleReducer reducer, double base)
          Replaces each element with the cumulation of applying the given reducer to all previous values, and returns the total reduction.
 double precumulateSum()
          Replaces each element with its prefix sum
 void removeAll()
          Removes from the array all elements matching bound and/or filter constraints.
 void removeConsecutiveDuplicates()
          Removes consecutive elements that are equal (or null), shifting others leftward, and possibly decreasing size.
 int size()
          Returns the number of elements within bounds
 void sort()
          Sorts the elements, assuming all elements are Comparable.
 void sort(Ops.DoubleComparator cmp)
          Sorts the elements.
 ParallelDoubleArray.WithBounds withBounds(int firstIndex, int upperBound)
          Returns an operation prefix that causes a method to operate only on the elements of the array between firstIndex (inclusive) and upperBound (exclusive).
 ParallelDoubleArray.WithFilter withFilter(Ops.DoublePredicate 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
 ParallelDoubleArray.WithDoubleMapping withMapping(Ops.DoubleMapper mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
<U> ParallelDoubleArray.WithMapping<U>
withMapping(Ops.MapperFromDouble<? extends U> mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
 ParallelDoubleArray.WithLongMapping withMapping(Ops.MapperFromDoubleToLong 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 jsr166y.forkjoin.ParallelDoubleArray.WithFilter
replaceWithCombination, replaceWithCombination, replaceWithCombination, replaceWithGeneratedValue, replaceWithMappedIndex, replaceWithTransform, replaceWithValue
 
Methods inherited from class jsr166y.forkjoin.ParallelDoubleArray.WithDoubleMapping
apply, max, max, min, min, reduce, sum, summary, summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withBounds

public ParallelDoubleArray.WithBounds withBounds(int firstIndex,
                                                 int upperBound)
Returns an operation prefix that causes a method to operate only on the elements of the array between firstIndex (inclusive) and upperBound (exclusive). The bound arguments are relative to the current bounds. For example pa.withBounds(2, 8).withBounds(3, 5) indexes the 5th (= 2+3) and 6th elements of pa. However, indices returned by methods such as indexOf are with respect to the underlying ParallelDoubleArray.

Parameters:
firstIndex - the lower bound (inclusive)
upperBound - the upper bound (exclusive)
Returns:
operation prefix

withFilter

public ParallelDoubleArray.WithFilter withFilter(Ops.DoublePredicate 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

Specified by:
withFilter in class ParallelDoubleArray.WithFilter
Parameters:
selector - the selector
Returns:
operation prefix

withMapping

public <U> ParallelDoubleArray.WithMapping<U> withMapping(Ops.MapperFromDouble<? extends 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 ParallelDoubleArray.WithDoubleMapping
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelDoubleArray.WithDoubleMapping withMapping(Ops.DoubleMapper 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 ParallelDoubleArray.WithDoubleMapping
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelDoubleArray.WithLongMapping withMapping(Ops.MapperFromDoubleToLong 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 ParallelDoubleArray.WithDoubleMapping
Parameters:
mapper - the mapper
Returns:
operation prefix

orFilter

public ParallelDoubleArray.WithFilter orFilter(Ops.DoublePredicate selector)
Description copied from class: ParallelDoubleArray.WithFilter
Returns an operation prefix that causes a method to operate only on elements for which the current selector (if present) or the given selector returns true

Specified by:
orFilter in class ParallelDoubleArray.WithFilter
Parameters:
selector - the selector
Returns:
operation prefix

anyIndex

public int anyIndex()
Description copied from class: ParallelDoubleArray.WithDoubleMapping
Returns the index of some element matching bound and filter constraints, or -1 if none.

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

combine

public ParallelDoubleArray combine(double[] other,
                                   Ops.DoubleReducer combiner)
Returns a ParallelDoubleArray 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 ParallelDoubleArray combine(ParallelDoubleArray other,
                                   Ops.DoubleReducer combiner)
Returns a ParallelDoubleArray 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> ParallelDoubleArray combine(ParallelDoubleArray.WithBounds other,
                                         Ops.DoubleReducer combiner)
Returns a ParallelDoubleArray containing results of applying combine(thisElement, otherElement) for each element.

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

all

public ParallelDoubleArray all()
Description copied from class: ParallelDoubleArray.WithDoubleMapping
Returns a new ParallelDoubleArray holding elements

Specified by:
all in class ParallelDoubleArray.WithDoubleMapping
Returns:
a new ParallelDoubleArray holding elements

allUniqueElements

public ParallelDoubleArray allUniqueElements()
Description copied from class: ParallelDoubleArray.WithFilter
Returns a new ParallelDoubleArray containing only unique elements (that is, without any duplicates).

Specified by:
allUniqueElements in class ParallelDoubleArray.WithFilter
Returns:
the new ParallelDoubleArray

indexOf

public int indexOf(double target)
Returns the index of some element equal to given target, or -1 if not present

Parameters:
target - the element to search for
Returns:
the index or -1 if not present

binarySearch

public int binarySearch(double target)
Assuming this array is sorted, returns the index of an element equal to given target, or -1 if not present. If the array is not sorted, the results are undefined.

Parameters:
target - the element to search for
Returns:
the index or -1 if not present

binarySearch

public int binarySearch(double target,
                        Ops.DoubleComparator comparator)
Assuming this array is sorted with respect to the given comparator, returns the index of an element equal to given target, or -1 if not present. If the array is not sorted, the results are undefined.

Parameters:
target - the element to search for
comparator - the comparator
Returns:
the index or -1 if not present

size

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

Specified by:
size in class ParallelDoubleArray.WithDoubleMapping
Returns:
the number of elements within bounds

cumulate

public void cumulate(Ops.DoubleReducer reducer,
                     double 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 double precumulate(Ops.DoubleReducer reducer,
                          double 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 double precumulateSum()
Replaces each element with its prefix sum

Returns:
the total sum

sort

public void sort(Ops.DoubleComparator 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.

removeAll

public void removeAll()
Description copied from class: ParallelDoubleArray.WithFilter
Removes from the array all elements matching bound and/or filter constraints.

Specified by:
removeAll in class ParallelDoubleArray.WithFilter

removeConsecutiveDuplicates

public void removeConsecutiveDuplicates()
Removes consecutive elements that are equal (or null), shifting others leftward, and possibly decreasing size. This method may be used after sorting to ensure that this ParallelDoubleArray contains a set of unique elements.