|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jsr166z.forkjoin.ParallelLongArray
public class ParallelLongArray
An array of longs supporting parallel operations. This class
provides methods supporting the same operations as ParallelArray
, but specialized for scalar long integers. It
additionally provides a few methods specific to numerical values.
Nested Class Summary | |
---|---|
static class |
ParallelLongArray.WithBounds
A restriction of parallel array operations to apply only within a given range of indices. |
static class |
ParallelLongArray.WithDoubleMapping
A modifier for parallel array operations to apply to mappings of elements to doubles, not to the elements themselves |
static class |
ParallelLongArray.WithFilter
A restriction of parallel array operations to apply only to elements for which a selector returns true |
static class |
ParallelLongArray.WithIntMapping
A modifier for parallel array operations to apply to mappings of elements to ints, not to the elements themselves |
static class |
ParallelLongArray.WithLongMapping
A modifier for parallel array operations to apply to mappings of elements to longs, not to the elements themselves |
static class |
ParallelLongArray.WithMapping<U>
A modifier for parallel array operations to apply to mappings of elements, not to the elements themselves |
Constructor Summary | |
---|---|
ParallelLongArray(ForkJoinExecutor executor,
int size)
Creates a new ParallelLongArray using the given executor and an array of the given size. |
|
ParallelLongArray(ForkJoinExecutor executor,
int size,
long[] sourceToCopy)
Creates a new ParallelLongArray 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. |
|
ParallelLongArray(ForkJoinExecutor executor,
long[] handoff)
Creates a new ParallelLongArray using the given executor and array. |
Method Summary | ||
---|---|---|
void |
apply({long=>void} procedure)
Applies the given procedure to elements |
|
ParallelLongArray |
combine(long[] other,
{long,long=>long} combiner)
Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element. |
|
ParallelLongArray |
combine(ParallelLongArray other,
{long,long=>long} combiner)
Returns a ParallelArray containing results of applying combine(thisElement, otherElement) for each element. |
|
void |
cumulate({long,long=>long} reducer,
long base)
Replaces each element with the running cumulation of applying the given reducer. |
|
void |
cumulateSum()
Replaces each element with the running sum |
|
long |
get(int i)
Returns the element of the array at the given index |
|
long[] |
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({long,long=>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({long,long=>int} comparator)
Returns the index of the least element , or -1 if empty |
|
long |
max()
Returns the maximum element, or Long.MIN_VALUE if empty assuming that all elements are Comparables |
|
long |
max({long,long=>int} comparator)
Returns the maximum element, or Long.MIN_VALUE if empty |
|
long |
min()
Returns the minimum element, or Long.MAX_VALUE if empty, assuming that all elements are Comparables |
|
long |
min({long,long=>int} comparator)
Returns the minimum element, or Long.MAX_VALUE if empty |
|
ParallelLongArray |
newArray()
Returns a new ParallelArray holding elements |
|
long |
precumulate({long,long=>long} reducer,
long base)
Replaces each element with the cumulation of applying the given reducer to all previous values, and returns the total reduction. |
|
long |
precumulateSum()
Replaces each element with its prefix sum |
|
void |
randomFill()
Sets each element to a uniform random value having the same properties as Random.nextLong() |
|
void |
randomFill(long bound)
Sets each element to a uniform random value having the same properties as Random.nextInt(int) |
|
long |
reduce({long,long=>long} reducer,
long base)
Returns reduction of elements |
|
void |
replaceWithCombination(long[] other,
{long,long=>long} combiner)
Replaces elements with results of applying combine(thisElement, otherElement) |
|
void |
replaceWithCombination(ParallelLongArray other,
{long,long=>long} combiner)
Replaces elements with results of applying combine(thisElement, otherElement) |
|
void |
replaceWithGeneratedValue({=>long} generator)
Replaces elements with the results of applying the given generator. |
|
void |
replaceWithMappedIndex({int=>long} mapper)
Replaces elements with the results of applying the given mapper to their indices. |
|
void |
replaceWithTransform({long=>long} mapper)
Replaces elements with the results of applying the given mapper to their current values. |
|
void |
replaceWithValue(long value)
Replaces elements with the given value. |
|
void |
set(int i,
long 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({long,long=>int} comparator)
Sorts the array |
|
long |
sum()
Returns the sum of elements |
|
ParallelLongArray.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). |
|
ParallelLongArray.WithFilter |
withFilter({long=>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 |
|
ParallelLongArray.WithDoubleMapping |
withMapping({long=>double} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper. |
|
ParallelLongArray.WithIntMapping |
withMapping({long=>int} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper. |
|
ParallelLongArray.WithLongMapping |
withMapping({long=>long} mapper)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper. |
|
|
withMapping({long=>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 ParallelLongArray(ForkJoinExecutor executor, long[] handoff)
executor
- the executorhandoff
- the arraypublic ParallelLongArray(ForkJoinExecutor executor, int size, long[] sourceToCopy)
executor
- the executorsize
- the array sizesourceToCopy
- the source of initial elementspublic ParallelLongArray(ForkJoinExecutor executor, int size)
executor
- the executorsize
- the array sizeMethod Detail |
---|
public ForkJoinExecutor getExecutor()
public long[] getArray()
public int size()
public long get(int i)
i
- the index
public void set(int i, long x)
i
- the indexx
- the valuepublic void apply({long=>void} procedure)
procedure
- the procedurepublic long reduce({long,long=>long} reducer, long base)
reducer
- the reducerbase
- the result for an empty array
public ParallelLongArray newArray()
public ParallelLongArray combine(long[] other, {long,long=>long} combiner)
other
- the other arraycombiner
- the combiner
java.lang.ArrayIndexOutOfBoundsException
- if other array is
shorter than this array.public ParallelLongArray combine(ParallelLongArray other, {long,long=>long} combiner)
other
- the other arraycombiner
- the combiner
java.lang.ArrayIndexOutOfBoundsException
- if other array is not
the same length as this array.public void replaceWithTransform({long=>long} mapper)
mapper
- the mapperpublic void replaceWithMappedIndex({int=>long} mapper)
mapper
- the mapperpublic void replaceWithGeneratedValue({=>long} generator)
generator
- the generatorpublic void randomFill()
Random.nextLong()
public void randomFill(long 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(long value)
value
- the valuepublic void replaceWithCombination(ParallelLongArray other, {long,long=>long} combiner)
other
- the other arraycombiner
- the combiner
java.lang.ArrayIndexOutOfBoundsException
- if other array has
fewer elements than this array.public void replaceWithCombination(long[] other, {long,long=>long} combiner)
other
- the other arraycombiner
- the combiner
java.lang.ArrayIndexOutOfBoundsException
- if other array has
fewer elements than this array.public int indexOfMin({long,long=>int} comparator)
comparator
- the comparator
public int indexOfMax({long,long=>int} comparator)
comparator
- the comparator
public int indexOfMin()
public int indexOfMax()
public long min({long,long=>int} comparator)
comparator
- the comparator
public long min()
public long max({long,long=>int} comparator)
comparator
- the comparator
public long max()
public long sum()
public void cumulate({long,long=>long} reducer, long base)
reducer
- the reducerbase
- the result for an empty arraypublic long precumulate({long,long=>long} reducer, long base)
reducer
- the reducerbase
- the result for an empty array
public void cumulateSum()
public long precumulateSum()
public void sort({long,long=>int} comparator)
comparator
- the comparator to usepublic void sort()
public ParallelLongArray.WithBounds withBounds(int firstIndex, int upperBound)
firstIndex
- the lower bound (inclusive)upperBound
- the upper bound (exclusive)
public ParallelLongArray.WithFilter withFilter({long=>boolean} selector)
selector
- the selector
public <U> ParallelLongArray.WithMapping<U> withMapping({long=>U} mapper)
mapper
- the mapper
public ParallelLongArray.WithDoubleMapping withMapping({long=>double} mapper)
mapper
- the mapper
public ParallelLongArray.WithLongMapping withMapping({long=>long} mapper)
mapper
- the mapper
public ParallelLongArray.WithIntMapping withMapping({long=>int} mapper)
mapper
- the mapper
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |