|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjsr166z.forkjoin.ParallelIntArray
public class ParallelIntArray
An array of ints supporting parallel operations. This class
provides methods supporting the same operations as ParallelArray, but specialized for scalar integers. It
additionally provides a few methods specific to numerical values.
| Nested Class Summary | |
|---|---|
static class |
ParallelIntArray.WithBounds
A restriction of parallel array operations to apply only within a given range of indices. |
static class |
ParallelIntArray.WithDoubleMapping
A modifier for parallel array operations to apply to mappings of elements to doubles, not to the elements themselves |
static class |
ParallelIntArray.WithFilter
A restriction of parallel array operations to apply only to elements for which a selector returns true |
static class |
ParallelIntArray.WithIntMapping
A modifier for parallel array operations to apply to mappings of elements to ints, not to the elements themselves |
static class |
ParallelIntArray.WithLongMapping
A modifier for parallel array operations to apply to mappings of elements to longs, not to the elements themselves |
static class |
ParallelIntArray.WithMapping<U>
A modifier for parallel array operations to apply to mappings of elements, not to the elements themselves |
| Constructor Summary | |
|---|---|
ParallelIntArray(ForkJoinExecutor executor,
int size)
Creates a new ParallelIntArray using the given executor and an array of the given size. |
|
ParallelIntArray(ForkJoinExecutor executor,
int[] handoff)
Creates a new ParallelIntArray using the given executor and array. |
|
ParallelIntArray(ForkJoinExecutor executor,
int size,
int[] sourceToCopy)
Creates a new ParallelIntArray using the given executor and an array of the given size, initially holding copies of the given source truncated or padded with zero to obtain the specified length. |
|
| Method Summary | ||
|---|---|---|
void |
apply({int=>void} procedure)
Applies the given procedure to elements |
|
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 |
|
int |
get(int i)
Returns the element of the array at the given index |
|
int[] |
getArray()
Returns the underlying array used for computations |
|
ForkJoinExecutor |
getExecutor()
Returns the executor used for computations |
|
int |
indexOfMax()
Returns the index of the greatest element , or -1 if empty assuming that all elements are Comparables |
|
int |
indexOfMax({int,int=>int} comparator)
Returns the index of the greatest element , or -1 if empty |
|
int |
indexOfMin()
Returns the index of the least element , or -1 if empty assuming that all elements are Comparables |
|
int |
indexOfMin({int,int=>int} comparator)
Returns the index of 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 |
|
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 |
|
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 the 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. |
|
void |
set(int i,
int x)
Sets the element of the array at the given index to the given value |
|
int |
size()
Returns the length of the underlying array |
|
void |
sort()
Sorts the array, using natural comparator. |
|
void |
sort({int,int=>int} comparator)
Sorts the array |
|
int |
sum()
Returns the sum of elements |
|
ParallelIntArray.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). |
|
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. |
|
|
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ParallelIntArray(ForkJoinExecutor executor,
int[] handoff)
executor - the executorhandoff - the array
public ParallelIntArray(ForkJoinExecutor executor,
int size,
int[] sourceToCopy)
executor - the executorsize - the array sizesourceToCopy - the source of initial elements
public ParallelIntArray(ForkJoinExecutor executor,
int size)
executor - the executorsize - the array size| Method Detail |
|---|
public ForkJoinExecutor getExecutor()
public int[] getArray()
public int size()
public int get(int i)
i - the index
public void set(int i,
int x)
i - the indexx - the value
public void apply({int=>void} procedure)
procedure - the procedure
public int reduce({int,int=>int} reducer,
int base)
reducer - the reducerbase - the result for an empty array
public ParallelIntArray newArray()
public ParallelIntArray combine(int[] other,
{int,int=>int} combiner)
other - the other arraycombiner - the combiner
java.lang.ArrayIndexOutOfBoundsException - if other array is
shorter than this array.
public ParallelIntArray combine(ParallelIntArray other,
{int,int=>int} combiner)
other - the other arraycombiner - the combiner
java.lang.ArrayIndexOutOfBoundsException - if other array is not
the same length as this array.
public void replaceWithTransform({int=>int} mapper)
mapper - the mapper
public void replaceWithMappedIndex({int=>int} mapper)
mapper - the mapper
public void replaceWithGeneratedValue({=>int} generator)
generator - the generatorpublic void randomFill()
Random.nextInt()
public void randomFill(int bound)
Random.nextInt(int)
bound - the upper bound of each random value
java.lang.IllegalArgumentException - if bound less than or equal to zeropublic void replaceWithValue(int value)
value - the value
public void replaceWithCombination(ParallelIntArray other,
{int,int=>int} combiner)
other - the other arraycombiner - the combiner
java.lang.ArrayIndexOutOfBoundsException - if other array has
fewer elements than this array.
public void replaceWithCombination(int[] other,
{int,int=>int} combiner)
other - the other arraycombiner - the combiner
java.lang.ArrayIndexOutOfBoundsException - if other array has
fewer elements than this array.
public int indexOfMin({int,int=>int} comparator)
comparator - the comparator
public int indexOfMax({int,int=>int} comparator)
comparator - the comparator
public int indexOfMin()
public int indexOfMax()
public int min({int,int=>int} comparator)
comparator - the comparator
public int min()
public int max({int,int=>int} comparator)
comparator - the comparator
public int max()
public int sum()
public void cumulate({int,int=>int} reducer,
int base)
reducer - the reducerbase - the result for an empty array
public int precumulate({int,int=>int} reducer,
int base)
reducer - the reducerbase - the result for an empty array
public void cumulateSum()
public int precumulateSum()
public void sort({int,int=>int} comparator)
comparator - the comparator to usepublic void sort()
public ParallelIntArray.WithBounds withBounds(int firstIndex,
int upperBound)
firstIndex - the lower bound (inclusive)upperBound - the upper bound (exclusive)
public ParallelIntArray.WithFilter withFilter({int=>boolean} selector)
selector - the selector
public <U> ParallelIntArray.WithMapping<U> withMapping({int=>U} mapper)
mapper - the mapper
public ParallelIntArray.WithDoubleMapping withMapping({int=>double} mapper)
mapper - the mapper
public ParallelIntArray.WithLongMapping withMapping({int=>long} mapper)
mapper - the mapper
public ParallelIntArray.WithIntMapping withMapping({int=>int} mapper)
mapper - the mapper
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||