|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.extra166y.AbstractParallelAnyArray.DUPap groovyx.gpars.extra166y.ParallelDoubleArray
public class ParallelDoubleArray extends DUPap
An array of doubles supporting parallel operations. This class provides methods supporting the same operations as ParallelArray, but specialized for scalar doubles. It additionally provides a few methods specific to numerical values.
Nested Class Summary | |
---|---|
class |
ParallelDoubleArray.AsList
|
class |
ParallelDoubleArray.ListIter
|
static class |
ParallelDoubleArray.ParallelDoubleArrayIterator
|
static interface |
ParallelDoubleArray.SummaryStatistics
Summary statistics for a possibly bounded, filtered, and/or mapped ParallelDoubleArray. |
Field Summary | |
---|---|
ParallelDoubleArray.AsList |
listView
|
Constructor Summary | |
protected ParallelDoubleArray(ForkJoinPool executor, double[] array, int limit)
Constructor for use by subclasses to create a new ParallelDoubleArray using the given executor, and initially using the supplied array, with effective size bound by the given limit. |
|
ParallelDoubleArray(ForkJoinPool executor, double[] array)
Trusted internal version of protected constructor. |
Method Summary | |
---|---|
ParallelDoubleArray
|
addAll(double[] other)
Equivalent to |
ParallelDoubleArray
|
addAll(ParallelDoubleArrayWithDoubleMapping other)
Appends all (possibly bounded, filtered, or mapped) elements of the given ParallelDoubleArray, resizing and/or reallocating this array if necessary. |
ParallelDoubleArray
|
all()
Returns a new ParallelDoubleArray holding all elements. |
ParallelDoubleArray
|
allUniqueElements()
Returns a new ParallelDoubleArray containing only the unique elements of this array (that is, without any duplicates). |
void
|
appendElement(double e)
|
void
|
apply(DoubleProcedure procedure)
|
java.util.List
|
asList()
Returns a view of this ParallelDoubleArray as a List. |
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, 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. |
static ParallelDoubleArray
|
create(int size, ForkJoinPool executor)
Creates a new ParallelDoubleArray using the given executor and an array of the given size. |
static ParallelDoubleArray
|
createEmpty(int size, ForkJoinPool executor)
Creates a new ParallelDoubleArray using the given executor and an array of the given size, but with an initial effective size of zero, enabling incremental insertion via ParallelDoubleArray#asList#asList operations. |
static ParallelDoubleArray
|
createFromCopy(double[] source, ForkJoinPool executor)
Creates a new ParallelDoubleArray using the given executor and initially holding copies of the given source elements. |
static ParallelDoubleArray
|
createFromCopy(int size, double[] source, ForkJoinPool executor)
Creates a new ParallelDoubleArray using an array of the given size, initially holding copies of the given source truncated or padded with zeros to obtain the specified length. |
static ParallelDoubleArray
|
createUsingHandoff(double[] handoff, ForkJoinPool executor)
Creates a new ParallelDoubleArray initially using the given array and executor. |
ParallelDoubleArray
|
cumulate(DoubleReducer reducer, double base)
Replaces each element with the running cumulation of applying the given reducer. |
ParallelDoubleArray
|
cumulateSum()
|
static ForkJoinPool
|
defaultExecutor()
Returns a common default executor for use in ParallelArrays. |
double
|
get(int i)
|
double[]
|
getArray()
|
ForkJoinPool
|
getExecutor()
|
boolean
|
hasAllEqualElements(ParallelDoubleArrayWithDoubleMapping other)
Returns true if all elements at the same relative positions of this and other array are equal. |
int
|
indexOf(double target)
Returns the index of some element equal to given target, or -1 if not present. |
void
|
insertElementAt(int index, double e)
|
void
|
insertSlotsAt(int index, int len)
Makes len slots available at index. |
java.util.Iterator
|
iterator()
Returns an iterator stepping through each element of the array up to the current limit. |
double
|
max(DoubleComparator comparator)
Returns the maximum element, or -Double.MAX_VALUE if empty. |
double
|
max()
Returns the maximum element, or -Double.MAX_VALUE if empty. |
double
|
min(DoubleComparator comparator)
Returns the minimum element, or Double.MAX_VALUE if empty. |
double
|
min()
Returns the minimum element, or Double.MAX_VALUE if empty. |
double
|
precumulate(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. |
double
|
reduce(DoubleReducer reducer, double base)
Returns reduction of elements. |
ParallelDoubleArray
|
removeAll(DoublePredicate selector)
|
ParallelDoubleArray
|
removeConsecutiveDuplicates()
Removes consecutive elements that are equal, shifting others leftward, and possibly decreasing size. |
void
|
removeSlotAt(int index)
|
void
|
removeSlotsAt(int fromIndex, int toIndex)
|
ParallelDoubleArray
|
replaceWithGeneratedValue(DoubleGenerator generator)
Replaces elements with the results of applying the given generator. |
ParallelDoubleArray
|
replaceWithMappedIndex(IntToDouble op)
Replaces elements with the results of applying the given op to their indices. |
ParallelDoubleArray
|
replaceWithMappedIndex(IntAndDoubleToDouble op)
Replaces elements with the results of applying the given mapping to each index and current element value. |
ParallelDoubleArray
|
replaceWithMapping(DoubleOp op)
Replaces elements with the results of applying the given op to their current values. |
ParallelDoubleArray
|
replaceWithMapping(BinaryDoubleOp combiner, ParallelDoubleArrayWithDoubleMapping other)
Replaces elements with results of applying
|
ParallelDoubleArray
|
replaceWithMapping(BinaryDoubleOp combiner, double[] other)
Replaces elements with results of applying
|
ParallelDoubleArray
|
replaceWithValue(double value)
Replaces elements with the given value. |
void
|
resizeArray(int newCap)
|
int
|
seqIndexOf(double target)
|
int
|
seqLastIndexOf(double target)
|
void
|
set(int i, double x)
Equivalent to |
void
|
setLimit(int newLimit)
|
int
|
size()
Returns the effective size of the underlying array. |
ParallelDoubleArray
|
sort(DoubleComparator comparator)
Sorts the array. |
ParallelDoubleArray
|
sort()
Sorts the array, assuming all elements are Comparable. |
double
|
sum()
Returns the sum of elements. |
SummaryStatistics
|
summary(DoubleComparator comparator)
Returns summary statistics, using the given comparator to locate minimum and maximum elements. |
SummaryStatistics
|
summary()
Returns summary statistics, using natural comparator. |
java.lang.String
|
toString()
|
ParallelDoubleArrayWithBounds
|
withBounds(int firstIndex, int upperBound)
|
ParallelDoubleArrayWithFilter
|
withFilter(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. |
ParallelDoubleArrayWithFilter
|
withFilter(BinaryDoublePredicate selector, ParallelDoubleArrayWithDoubleMapping other)
|
ParallelDoubleArrayWithFilter
|
withIndexedFilter(IntAndDoublePredicate selector)
Returns an operation prefix that causes a method to operate only on elements for which the given indexed selector returns true. |
ParallelDoubleArrayWithMapping
|
withIndexedMapping(IntAndDoubleToObject mapper)
Returns an operation prefix that causes a method to operate on mappings of this array using the given mapper that accepts as arguments an element's current index and value, and produces a new value. |
ParallelDoubleArrayWithDoubleMapping
|
withIndexedMapping(IntAndDoubleToDouble mapper)
Returns an operation prefix that causes a method to operate on mappings of this array using the given mapper that accepts as arguments an element's current index and value, and produces a new value. |
ParallelDoubleArrayWithLongMapping
|
withIndexedMapping(IntAndDoubleToLong mapper)
Returns an operation prefix that causes a method to operate on mappings of this array using the given mapper that accepts as arguments an element's current index and value, and produces a new value. |
ParallelDoubleArrayWithMapping
|
withMapping(DoubleToObject op)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given op. |
ParallelDoubleArrayWithDoubleMapping
|
withMapping(DoubleOp op)
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given op. |
ParallelDoubleArrayWithLongMapping
|
withMapping(DoubleToLong op)
|
ParallelDoubleArrayWithMapping
|
withMapping(DoubleAndObjectToObject combiner, ParallelArrayWithMapping other)
|
ParallelDoubleArrayWithMapping
|
withMapping(DoubleAndDoubleToObject combiner, ParallelDoubleArrayWithDoubleMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithMapping
|
withMapping(DoubleAndLongToObject combiner, ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithDoubleMapping
|
withMapping(DoubleAndObjectToDouble combiner, ParallelArrayWithMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithDoubleMapping
|
withMapping(BinaryDoubleOp combiner, ParallelDoubleArrayWithDoubleMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithDoubleMapping
|
withMapping(DoubleAndLongToDouble combiner, ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithLongMapping
|
withMapping(DoubleAndObjectToLong combiner, ParallelArrayWithMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithLongMapping
|
withMapping(DoubleAndDoubleToLong combiner, ParallelDoubleArrayWithDoubleMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
ParallelDoubleArrayWithLongMapping
|
withMapping(DoubleAndLongToLong combiner, ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate on binary mappings of this array and the other array. |
Field Detail |
---|
ParallelDoubleArray.AsList listView
Constructor Detail |
---|
protected ParallelDoubleArray(ForkJoinPool executor, double[] array, int limit)
executor
- the executorarray
- the arraylimit
- the upper bound limit
ParallelDoubleArray(ForkJoinPool executor, double[] array)
Method Detail |
---|
public ParallelDoubleArray addAll(double[] other)
asList().addAll
but specialized for
array arguments and likely to be more efficient.
other
- the elements to add
public ParallelDoubleArray addAll(ParallelDoubleArrayWithDoubleMapping other)
other
- the elements to add
public ParallelDoubleArray all()
public ParallelDoubleArray allUniqueElements()
final void appendElement(double e)
public void apply(DoubleProcedure procedure)
public java.util.List asList()
public int binarySearch(double target)
target
- the element to search for
public int binarySearch(double target, DoubleComparator comparator)
target
- the element to search forcomparator
- the comparator
public static ParallelDoubleArray create(int size, ForkJoinPool executor)
size
- the array sizeexecutor
- the executor
public static ParallelDoubleArray createEmpty(int size, ForkJoinPool executor)
size
- the array sizeexecutor
- the executor
public static ParallelDoubleArray createFromCopy(double[] source, ForkJoinPool executor)
source
- the source of initial elementsexecutor
- the executor
public static ParallelDoubleArray createFromCopy(int size, double[] source, ForkJoinPool executor)
source
- the source of initial elementssize
- the array sizeexecutor
- the executor
public static ParallelDoubleArray createUsingHandoff(double[] handoff, ForkJoinPool executor)
handoff
- the arrayexecutor
- the executor
public ParallelDoubleArray cumulate(DoubleReducer reducer, double base)
1, 2, 3
, and the reducer operation adds numbers, then
after invocation of this method, the contents would be 1,
3, 6
(that is, 1, 1+2, 1+2+3
).
reducer
- the reducerbase
- the result for an empty array
public ParallelDoubleArray cumulateSum()
public static ForkJoinPool defaultExecutor()
public double get(int i)
public double[] getArray()
public ForkJoinPool getExecutor()
public boolean hasAllEqualElements(ParallelDoubleArrayWithDoubleMapping other)
other
- the other array
public int indexOf(double target)
target
- the element to search for
final void insertElementAt(int index, double e)
final void insertSlotsAt(int index, int len)
public java.util.Iterator iterator()
ListIterator
supporting add, remove, and set
operations is available via asList.
public double max(DoubleComparator comparator)
comparator
- the comparator
public double max()
public double min(DoubleComparator comparator)
comparator
- the comparator
public double min()
public double precumulate(DoubleReducer reducer, double base)
1,
2, 3
, and the reducer operation adds numbers, then after
invocation of this method, the contents would be 0, 1,
3
(that is, 0, 0+1, 0+1+2
, and the return value
would be 6 (that is, 1+2+3
).
reducer
- the reducerbase
- the result for an empty array
public double precumulateSum()
public double reduce(DoubleReducer reducer, double base)
reducer
- the reducerbase
- the result for an empty array
public ParallelDoubleArray removeAll(DoublePredicate selector)
public ParallelDoubleArray removeConsecutiveDuplicates()
final void removeSlotAt(int index)
final void removeSlotsAt(int fromIndex, int toIndex)
public ParallelDoubleArray replaceWithGeneratedValue(DoubleGenerator generator)
replaceWithGeneratedValue(Ops.doubleRandom())
.
generator
- the generator
public ParallelDoubleArray replaceWithMappedIndex(IntToDouble op)
op
- the op
public ParallelDoubleArray replaceWithMappedIndex(IntAndDoubleToDouble op)
op
- the op
public ParallelDoubleArray replaceWithMapping(DoubleOp op)
op
- the op
public ParallelDoubleArray replaceWithMapping(BinaryDoubleOp combiner, ParallelDoubleArrayWithDoubleMapping other)
op(thisElement, otherElement)
.other
- the other arraycombiner
- the combiner
public ParallelDoubleArray replaceWithMapping(BinaryDoubleOp combiner, double[] other)
op(thisElement, otherElement)
.other
- the other arraycombiner
- the combiner
public ParallelDoubleArray replaceWithValue(double value)
value
- the value
final void resizeArray(int newCap)
final int seqIndexOf(double target)
final int seqLastIndexOf(double target)
public void set(int i, double x)
asList().toString()
.
public final void setLimit(int newLimit)
public int size()
public ParallelDoubleArray sort(DoubleComparator comparator)
comparator
- the comparator to use
public ParallelDoubleArray sort()
public double sum()
public SummaryStatistics summary(DoubleComparator comparator)
comparator
- the comparator to use for
locating minimum and maximum elements
public SummaryStatistics summary()
public java.lang.String toString()
public ParallelDoubleArrayWithBounds withBounds(int firstIndex, int upperBound)
public ParallelDoubleArrayWithFilter withFilter(DoublePredicate selector)
selector
- the selector
public ParallelDoubleArrayWithFilter withFilter(BinaryDoublePredicate selector, ParallelDoubleArrayWithDoubleMapping other)
public ParallelDoubleArrayWithFilter withIndexedFilter(IntAndDoublePredicate selector)
selector
- the selector
public ParallelDoubleArrayWithMapping withIndexedMapping(IntAndDoubleToObject mapper)
mapper
- the mapper
public ParallelDoubleArrayWithDoubleMapping withIndexedMapping(IntAndDoubleToDouble mapper)
mapper
- the mapper
public ParallelDoubleArrayWithLongMapping withIndexedMapping(IntAndDoubleToLong mapper)
mapper
- the mapper
public ParallelDoubleArrayWithMapping withMapping(DoubleToObject op)
op
- the op
public ParallelDoubleArrayWithDoubleMapping withMapping(DoubleOp op)
op
- the op
public ParallelDoubleArrayWithLongMapping withMapping(DoubleToLong op)
public ParallelDoubleArrayWithMapping withMapping(DoubleAndObjectToObject combiner, ParallelArrayWithMapping other)
public ParallelDoubleArrayWithMapping withMapping(DoubleAndDoubleToObject combiner, ParallelDoubleArrayWithDoubleMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithMapping withMapping(DoubleAndLongToObject combiner, ParallelLongArrayWithLongMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithDoubleMapping withMapping(DoubleAndObjectToDouble combiner, ParallelArrayWithMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithDoubleMapping withMapping(BinaryDoubleOp combiner, ParallelDoubleArrayWithDoubleMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithDoubleMapping withMapping(DoubleAndLongToDouble combiner, ParallelLongArrayWithLongMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithLongMapping withMapping(DoubleAndObjectToLong combiner, ParallelArrayWithMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithLongMapping withMapping(DoubleAndDoubleToLong combiner, ParallelDoubleArrayWithDoubleMapping other)
combiner
- the combinerother
- the other array
public ParallelDoubleArrayWithLongMapping withMapping(DoubleAndLongToLong combiner, ParallelLongArrayWithLongMapping other)
combiner
- the combinerother
- the other array
Copyright © 2008–2013 Václav Pech. All Rights Reserved.