public class ParallelLongArray extends AbstractParallelAnyArray.LUPap
ParallelArray
, but specialized for scalar longs. It additionally
provides a few methods specific to numerical values.
Sample usages. Here is a complete (although naive) prime filter program:
import java.math.BigInteger; import jsr166y.*; import static extra166y.Ops.*; import static extra166y.ParallelLongArray.*; public class Sieve { public static void main(String[] args) { int n = Integer.parseInt(args[0]); // create array of divisors ParallelLongArray a = create(n-1, defaultExecutor()); a.replaceWithMappedIndex(add2); int i = 0; long p = 2; while (p * p < n) { // repeatedly filter a = a.withFilter(notDivisibleBy(p)).all(); p = a.get(++i); } System.out.printf("sieve(%d) = %s%n", n, a); // check result if (!a.withFilter(notProbablePrime).isEmpty()) throw new Error(); } static IntToLong add2 = new IntToLong() { public long op(int i) { return i + 2; } }; static LongPredicate notDivisibleBy(final long p) { return new LongPredicate() { public boolean op(long n) { return n <= p || (n % p) != 0; } }; } static LongPredicate notProbablePrime = new LongPredicate() { private static final int CERTAINTY = 8; public boolean op(long n) { return !BigInteger.valueOf(n).isProbablePrime(CERTAINTY); } }; }
Modifier and Type | Class and Description |
---|---|
(package private) class |
ParallelLongArray.AsList |
(package private) class |
ParallelLongArray.ListIter |
(package private) static class |
ParallelLongArray.ParallelLongArrayIterator |
static interface |
ParallelLongArray.SummaryStatistics
Summary statistics for a possibly bounded, filtered, and/or
mapped ParallelLongArray.
|
AbstractParallelAnyArray.AndPredicate<T>, AbstractParallelAnyArray.DDCPap, AbstractParallelAnyArray.DDMPap, AbstractParallelAnyArray.DFDCPap, AbstractParallelAnyArray.DFDMPap, AbstractParallelAnyArray.DFLCPap, AbstractParallelAnyArray.DFLMPap, AbstractParallelAnyArray.DFOCPap<U>, AbstractParallelAnyArray.DFOMPap<U>, AbstractParallelAnyArray.DFPap, AbstractParallelAnyArray.DLCPap, AbstractParallelAnyArray.DLMPap, AbstractParallelAnyArray.DOCPap<U>, AbstractParallelAnyArray.DOMPap<U>, AbstractParallelAnyArray.DPap, AbstractParallelAnyArray.DRDCPap, AbstractParallelAnyArray.DRDMPap, AbstractParallelAnyArray.DRLCPap, AbstractParallelAnyArray.DRLMPap, AbstractParallelAnyArray.DROCPap<U>, AbstractParallelAnyArray.DROMPap<U>, AbstractParallelAnyArray.DRPap, AbstractParallelAnyArray.DUDCPap, AbstractParallelAnyArray.DUDMPap, AbstractParallelAnyArray.DULCPap, AbstractParallelAnyArray.DULMPap, AbstractParallelAnyArray.DUOCPap<U>, AbstractParallelAnyArray.DUOMPap<U>, AbstractParallelAnyArray.DUPap, AbstractParallelAnyArray.FilteredAsDoubleIterator, AbstractParallelAnyArray.FilteredAsLongIterator, AbstractParallelAnyArray.FilteredIterator<U>, AbstractParallelAnyArray.LDCPap, AbstractParallelAnyArray.LDMPap, AbstractParallelAnyArray.LFDCPap, AbstractParallelAnyArray.LFDMPap, AbstractParallelAnyArray.LFLCPap, AbstractParallelAnyArray.LFLMPap, AbstractParallelAnyArray.LFOCPap<U>, AbstractParallelAnyArray.LFOMPap<U>, AbstractParallelAnyArray.LFPap, AbstractParallelAnyArray.LLCPap, AbstractParallelAnyArray.LLMPap, AbstractParallelAnyArray.LOCPap<U>, AbstractParallelAnyArray.LOMPap<U>, AbstractParallelAnyArray.LPap, AbstractParallelAnyArray.LRDCPap, AbstractParallelAnyArray.LRDMPap, AbstractParallelAnyArray.LRLCPap, AbstractParallelAnyArray.LRLMPap, AbstractParallelAnyArray.LROCPap<U>, AbstractParallelAnyArray.LROMPap<U>, AbstractParallelAnyArray.LRPap, AbstractParallelAnyArray.LUDCPap, AbstractParallelAnyArray.LUDMPap, AbstractParallelAnyArray.LULCPap, AbstractParallelAnyArray.LULMPap, AbstractParallelAnyArray.LUOCPap<U>, AbstractParallelAnyArray.LUOMPap<U>, AbstractParallelAnyArray.LUPap, AbstractParallelAnyArray.ODCPap<T>, AbstractParallelAnyArray.ODMPap<T>, AbstractParallelAnyArray.OFDCPap<T>, AbstractParallelAnyArray.OFDMPap<T>, AbstractParallelAnyArray.OFLCPap<T>, AbstractParallelAnyArray.OFLMPap<T>, AbstractParallelAnyArray.OFOCPap<T,U>, AbstractParallelAnyArray.OFOMPap<T,U>, AbstractParallelAnyArray.OFPap<T>, AbstractParallelAnyArray.OLCPap<T>, AbstractParallelAnyArray.OLMPap<T>, AbstractParallelAnyArray.OOCPap<T,U>, AbstractParallelAnyArray.OOMPap<T,U>, AbstractParallelAnyArray.OPap<T>, AbstractParallelAnyArray.ORDCPap<T>, AbstractParallelAnyArray.ORDMPap<T>, AbstractParallelAnyArray.ORLCPap<T>, AbstractParallelAnyArray.ORLMPap<T>, AbstractParallelAnyArray.OROCPap<T,U>, AbstractParallelAnyArray.OROMPap<T,U>, AbstractParallelAnyArray.ORPap<T>, AbstractParallelAnyArray.OUDCPap<T>, AbstractParallelAnyArray.OUDMPap<T>, AbstractParallelAnyArray.OULCPap<T>, AbstractParallelAnyArray.OULMPap<T>, AbstractParallelAnyArray.OUOCPap<T,U>, AbstractParallelAnyArray.OUOMPap<T,U>, AbstractParallelAnyArray.OUPap<T>, AbstractParallelAnyArray.Sequentially<U>, AbstractParallelAnyArray.SequentiallyAsDouble, AbstractParallelAnyArray.SequentiallyAsLong, AbstractParallelAnyArray.UnfilteredAsDoubleIterator, AbstractParallelAnyArray.UnfilteredAsLongIterator, AbstractParallelAnyArray.UnfilteredIterator<U>
Modifier and Type | Field and Description |
---|---|
(package private) ParallelLongArray.AsList |
listView |
array
ex, fence, origin, threshold
Modifier | Constructor and Description |
---|---|
(package private) |
ParallelLongArray(jsr166y.ForkJoinPool executor,
long[] array)
Trusted internal version of protected constructor.
|
protected |
ParallelLongArray(jsr166y.ForkJoinPool executor,
long[] array,
int limit)
Constructor for use by subclasses to create a new ParallelLongArray
using the given executor, and initially using the supplied
array, with effective size bound by the given limit.
|
Modifier and Type | Method and Description |
---|---|
ParallelLongArray |
addAll(long[] other)
Equivalent to
asList().addAll but specialized for array
arguments and likely to be more efficient. |
ParallelLongArray |
addAll(ParallelLongArrayWithLongMapping other)
Appends all (possibly bounded, filtered, or mapped) elements of
the given ParallelDoubleArray, resizing and/or reallocating this
array if necessary.
|
ParallelLongArray |
all()
Returns a new ParallelLongArray holding all elements.
|
ParallelLongArray |
allUniqueElements()
Returns a new ParallelLongArray containing only the unique
elements of this array (that is, without any duplicates).
|
(package private) void |
appendElement(long e) |
void |
apply(Ops.LongProcedure procedure)
Applies the given procedure to elements.
|
java.util.List<java.lang.Long> |
asList()
Returns a view of this ParallelLongArray as a List.
|
int |
binarySearch(long target)
Assuming this array is sorted, returns the index of an element
equal to given target, or -1 if not present.
|
int |
binarySearch(long target,
Ops.LongComparator 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 ParallelLongArray |
create(int size,
jsr166y.ForkJoinPool executor)
Creates a new ParallelLongArray using the given executor and
an array of the given size.
|
static ParallelLongArray |
createEmpty(int size,
jsr166y.ForkJoinPool executor)
Creates a new ParallelLongArray using the given executor and
an array of the given size, but with an initial effective size
of zero, enabling incremental insertion via
asList() operations. |
static ParallelLongArray |
createFromCopy(int size,
long[] source,
jsr166y.ForkJoinPool executor)
Creates a new ParallelLongArray 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 ParallelLongArray |
createFromCopy(long[] source,
jsr166y.ForkJoinPool executor)
Creates a new ParallelLongArray using the given executor and
initially holding copies of the given
source elements.
|
static ParallelLongArray |
createUsingHandoff(long[] handoff,
jsr166y.ForkJoinPool executor)
Creates a new ParallelLongArray initially using the given array and
executor.
|
ParallelLongArray |
cumulate(Ops.LongReducer reducer,
long base)
Replaces each element with the running cumulation of applying
the given reducer.
|
ParallelLongArray |
cumulateSum()
Replaces each element with the running sum.
|
static jsr166y.ForkJoinPool |
defaultExecutor()
Returns a common default executor for use in ParallelArrays.
|
long |
get(int i)
Returns the element of the array at the given index.
|
long[] |
getArray()
Returns the underlying array used for computations.
|
jsr166y.ForkJoinPool |
getExecutor()
Returns the executor used for computations.
|
boolean |
hasAllEqualElements(ParallelLongArrayWithLongMapping other)
Returns true if all elements at the same relative positions
of this and other array are equal.
|
int |
indexOf(long target)
Returns the index of some element equal to given target, or -1
if not present.
|
(package private) void |
insertElementAt(int index,
long e) |
(package private) void |
insertSlotsAt(int index,
int len)
Makes len slots available at index.
|
java.util.Iterator<java.lang.Long> |
iterator()
Returns an iterator stepping through each element of the array
up to the current limit.
|
long |
max()
Returns the maximum element, or Long.MIN_VALUE if empty.
|
long |
max(Ops.LongComparator comparator)
Returns the maximum element, or Long.MIN_VALUE if empty.
|
long |
min()
Returns the minimum element, or Long.MAX_VALUE if empty.
|
long |
min(Ops.LongComparator comparator)
Returns the minimum element, or Long.MAX_VALUE if empty.
|
long |
precumulate(Ops.LongReducer 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.
|
long |
reduce(Ops.LongReducer reducer,
long base)
Returns reduction of elements.
|
ParallelLongArray |
removeAll(Ops.LongPredicate selector)
Removes from the array all elements for which the given
selector holds.
|
ParallelLongArray |
removeConsecutiveDuplicates()
Removes consecutive elements that are equal,
shifting others leftward, and possibly decreasing size.
|
(package private) void |
removeSlotAt(int index) |
(package private) void |
removeSlotsAt(int fromIndex,
int toIndex) |
(package private) void |
replaceElementsParallelLongArrayWith(long[] a) |
ParallelLongArray |
replaceWithGeneratedValue(Ops.LongGenerator generator)
Replaces elements with the results of applying the given
generator.
|
ParallelLongArray |
replaceWithMappedIndex(Ops.IntAndLongToLong op)
Replaces elements with the results of applying the given
mapping to each index and current element value.
|
ParallelLongArray |
replaceWithMappedIndex(Ops.IntToLong op)
Replaces elements with the results of applying the given
op to their indices.
|
ParallelLongArray |
replaceWithMapping(Ops.BinaryLongOp combiner,
long[] other)
Replaces elements with results of applying
op(thisElement, otherElement) . |
ParallelLongArray |
replaceWithMapping(Ops.BinaryLongOp combiner,
ParallelLongArrayWithLongMapping other)
Replaces elements with results of applying
op(thisElement, otherElement) . |
ParallelLongArray |
replaceWithMapping(Ops.LongOp op)
Replaces elements with the results of applying the given op
to their current values.
|
ParallelLongArray |
replaceWithValue(long value)
Replaces elements with the given value.
|
(package private) void |
resizeArray(int newCap) |
(package private) int |
seqIndexOf(long target) |
(package private) int |
seqLastIndexOf(long target) |
void |
set(int i,
long x)
Sets the element of the array at the given index to the given value.
|
void |
setLimit(int newLimit)
Ensures that the underlying array can be accessed up to the
given upper bound, reallocating and copying the underlying
array to expand if necessary.
|
int |
size()
Returns the effective size of the underlying array.
|
ParallelLongArray |
sort()
Sorts the array, assuming all elements are Comparable.
|
ParallelLongArray |
sort(Ops.LongComparator comparator)
Sorts the array.
|
long |
sum()
Returns the sum of elements.
|
ParallelLongArray.SummaryStatistics |
summary()
Returns summary statistics, using natural comparator.
|
ParallelLongArray.SummaryStatistics |
summary(Ops.LongComparator comparator)
Returns summary statistics, using the given comparator
to locate minimum and maximum elements.
|
java.lang.String |
toString()
Equivalent to
asList().toString() . |
ParallelLongArrayWithBounds |
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).
|
ParallelLongArrayWithFilter |
withFilter(Ops.BinaryLongPredicate selector,
ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate
only on elements for which the given binary selector returns
true.
|
ParallelLongArrayWithFilter |
withFilter(Ops.LongPredicate 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.
|
ParallelLongArrayWithFilter |
withIndexedFilter(Ops.IntAndLongPredicate selector)
Returns an operation prefix that causes a method to operate
only on elements for which the given indexed selector returns
true.
|
ParallelLongArrayWithDoubleMapping |
withIndexedMapping(Ops.IntAndLongToDouble 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.
|
ParallelLongArrayWithLongMapping |
withIndexedMapping(Ops.IntAndLongToLong 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.
|
<U> ParallelLongArrayWithMapping<U> |
withIndexedMapping(Ops.IntAndLongToObject<? extends U> 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.
|
ParallelLongArrayWithLongMapping |
withMapping(Ops.BinaryLongOp combiner,
ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
ParallelLongArrayWithDoubleMapping |
withMapping(Ops.LongAndDoubleToDouble combiner,
ParallelDoubleArrayWithDoubleMapping other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
ParallelLongArrayWithLongMapping |
withMapping(Ops.LongAndDoubleToLong combiner,
ParallelDoubleArrayWithDoubleMapping other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
<V> ParallelLongArrayWithMapping<V> |
withMapping(Ops.LongAndDoubleToObject<? extends V> combiner,
ParallelDoubleArrayWithDoubleMapping other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
ParallelLongArrayWithDoubleMapping |
withMapping(Ops.LongAndLongToDouble combiner,
ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
<V> ParallelLongArrayWithMapping<V> |
withMapping(Ops.LongAndLongToObject<? extends V> combiner,
ParallelLongArrayWithLongMapping other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
<V,W> ParallelLongArrayWithDoubleMapping |
withMapping(Ops.LongAndObjectToDouble<? super V> combiner,
ParallelArrayWithMapping<W,V> other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
<V,W> ParallelLongArrayWithLongMapping |
withMapping(Ops.LongAndObjectToLong<? super V> combiner,
ParallelArrayWithMapping<W,V> other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
<V,W,X> ParallelLongArrayWithMapping<W> |
withMapping(Ops.LongAndObjectToObject<? super V,? extends W> combiner,
ParallelArrayWithMapping<X,V> other)
Returns an operation prefix that causes a method to operate
on binary mappings of this array and the other array.
|
ParallelLongArrayWithLongMapping |
withMapping(Ops.LongOp op)
Returns an operation prefix that causes a method to operate
on mapped elements of the array using the given op.
|
ParallelLongArrayWithDoubleMapping |
withMapping(Ops.LongToDouble op)
Returns an operation prefix that causes a method to operate
on mapped elements of the array using the given op.
|
<U> ParallelLongArrayWithMapping<U> |
withMapping(Ops.LongToObject<? extends U> op)
Returns an operation prefix that causes a method to operate
on mapped elements of the array using the given op.
|
leafApply, leafBinaryIndexMap, leafCombineInPlace, leafCombineInPlace, leafFill, leafGenerate, leafIndexMap, leafReduce, leafTransform
leafTransfer, leafTransferByIndex, lget
sequentially
dget, leafMoveByIndex, leafMoveSelected, lgetArray, oget
allDoubles, allLongs, allObjects, anyIndex, boundsCheck, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedOp, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, compoundIndexedSelector, computeThreshold, dgetArray, getThreshold, hasFilter, hasMap, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedMapper, indexedSelector, indexedSelector, indexedSelector, isEmpty, isSelected, leafApply, leafApply, leafBinaryIndexMap, leafBinaryIndexMap, leafCombineInPlace, leafCombineInPlace, leafCombineInPlace, leafCombineInPlace, leafFill, leafFill, leafGenerate, leafGenerate, leafIndexMap, leafIndexMap, leafIndexSelected, leafReduce, leafReduce, leafTransfer, leafTransfer, leafTransferByIndex, leafTransferByIndex, leafTransform, leafTransform, ogetArray
ParallelLongArray.AsList listView
protected ParallelLongArray(jsr166y.ForkJoinPool executor, long[] array, int limit)
create(int, jsr166y.ForkJoinPool)
,
createEmpty(int, jsr166y.ForkJoinPool)
, createUsingHandoff(long[], jsr166y.ForkJoinPool)
or createFromCopy(long[], jsr166y.ForkJoinPool)
.executor
- the executorarray
- the arraylimit
- the upper bound limitParallelLongArray(jsr166y.ForkJoinPool executor, long[] array)
public static jsr166y.ForkJoinPool defaultExecutor()
public static ParallelLongArray create(int size, jsr166y.ForkJoinPool executor)
size
- the array sizeexecutor
- the executorpublic static ParallelLongArray createUsingHandoff(long[] handoff, jsr166y.ForkJoinPool executor)
handoff
- the arrayexecutor
- the executorpublic static ParallelLongArray createFromCopy(long[] source, jsr166y.ForkJoinPool executor)
source
- the source of initial elementsexecutor
- the executorpublic static ParallelLongArray createFromCopy(int size, long[] source, jsr166y.ForkJoinPool executor)
source
- the source of initial elementssize
- the array sizeexecutor
- the executorpublic static ParallelLongArray createEmpty(int size, jsr166y.ForkJoinPool executor)
asList()
operations.size
- the array sizeexecutor
- the executorpublic jsr166y.ForkJoinPool getExecutor()
public void apply(Ops.LongProcedure procedure)
apply
in class ParallelLongArrayWithLongMapping
procedure
- the procedurepublic long reduce(Ops.LongReducer reducer, long base)
reduce
in class ParallelLongArrayWithLongMapping
reducer
- the reducerbase
- the result for an empty arraypublic ParallelLongArray all()
all
in class ParallelLongArrayWithLongMapping
public ParallelLongArray replaceWithMapping(Ops.LongOp op)
replaceWithMapping
in class ParallelLongArrayWithFilter
op
- the oppublic ParallelLongArray replaceWithMappedIndex(Ops.IntToLong op)
replaceWithMappedIndex
in class ParallelLongArrayWithFilter
op
- the oppublic ParallelLongArray replaceWithMappedIndex(Ops.IntAndLongToLong op)
replaceWithMappedIndex
in class ParallelLongArrayWithFilter
op
- the oppublic ParallelLongArray replaceWithGeneratedValue(Ops.LongGenerator generator)
replaceWithGeneratedValue(Ops.longRandom())
.replaceWithGeneratedValue
in class ParallelLongArrayWithFilter
generator
- the generatorpublic ParallelLongArray replaceWithValue(long value)
replaceWithValue
in class ParallelLongArrayWithFilter
value
- the valuepublic ParallelLongArray replaceWithMapping(Ops.BinaryLongOp combiner, ParallelLongArrayWithLongMapping other)
op(thisElement, otherElement)
.replaceWithMapping
in class ParallelLongArrayWithFilter
other
- the other arraycombiner
- the combinerpublic ParallelLongArray replaceWithMapping(Ops.BinaryLongOp combiner, long[] other)
op(thisElement, otherElement)
.replaceWithMapping
in class ParallelLongArrayWithFilter
other
- the other arraycombiner
- the combinerjava.lang.ArrayIndexOutOfBoundsException
- if other array has
fewer elements than this arraypublic int indexOf(long target)
indexOf
in class AbstractParallelAnyArray.LUPap
target
- the element to search forpublic int binarySearch(long target)
binarySearch
in class AbstractParallelAnyArray.LUPap
target
- the element to search forpublic int binarySearch(long target, Ops.LongComparator comparator)
binarySearch
in class AbstractParallelAnyArray.LUPap
target
- the element to search forcomparator
- the comparatorpublic ParallelLongArray.SummaryStatistics summary(Ops.LongComparator comparator)
summary
in class ParallelLongArrayWithLongMapping
comparator
- the comparator to use for
locating minimum and maximum elementspublic ParallelLongArray.SummaryStatistics summary()
summary
in class ParallelLongArrayWithLongMapping
public long min(Ops.LongComparator comparator)
min
in class ParallelLongArrayWithLongMapping
comparator
- the comparatorpublic long min()
min
in class ParallelLongArrayWithLongMapping
public long max(Ops.LongComparator comparator)
max
in class ParallelLongArrayWithLongMapping
comparator
- the comparatorpublic long max()
max
in class ParallelLongArrayWithLongMapping
public ParallelLongArray cumulate(Ops.LongReducer reducer, long 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
).cumulate
in class AbstractParallelAnyArray.LUPap
reducer
- the reducerbase
- the result for an empty arraypublic long precumulate(Ops.LongReducer reducer, long 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
).precumulate
in class AbstractParallelAnyArray.LUPap
reducer
- the reducerbase
- the result for an empty arraypublic ParallelLongArray sort(Ops.LongComparator comparator)
sort
in class AbstractParallelAnyArray.LUPap
comparator
- the comparator to usepublic ParallelLongArray sort()
sort
in class AbstractParallelAnyArray.LUPap
java.lang.ClassCastException
- if any element is not Comparablepublic ParallelLongArray removeConsecutiveDuplicates()
public ParallelLongArray addAll(long[] other)
asList().addAll
but specialized for array
arguments and likely to be more efficient.other
- the elements to addpublic ParallelLongArray addAll(ParallelLongArrayWithLongMapping other)
other
- the elements to addpublic ParallelLongArray allUniqueElements()
allUniqueElements
in class ParallelLongArrayWithFilter
public ParallelLongArray removeAll(Ops.LongPredicate selector)
selector
- the selectorpublic boolean hasAllEqualElements(ParallelLongArrayWithLongMapping other)
hasAllEqualElements
in class ParallelLongArrayWithFilter
other
- the other arraypublic long sum()
sum
in class ParallelLongArrayWithLongMapping
public ParallelLongArray cumulateSum()
cumulateSum
in class AbstractParallelAnyArray.LUPap
public long precumulateSum()
precumulateSum
in class AbstractParallelAnyArray.LUPap
public ParallelLongArrayWithBounds withBounds(int firstIndex, int upperBound)
withBounds
in class AbstractParallelAnyArray.LUPap
firstIndex
- the lower bound (inclusive)upperBound
- the upper bound (exclusive)public ParallelLongArrayWithFilter withFilter(Ops.LongPredicate selector)
withFilter
in class AbstractParallelAnyArray.LUPap
selector
- the selectorpublic ParallelLongArrayWithFilter withFilter(Ops.BinaryLongPredicate selector, ParallelLongArrayWithLongMapping other)
withFilter
in class ParallelLongArrayWithFilter
selector
- the selectorpublic ParallelLongArrayWithFilter withIndexedFilter(Ops.IntAndLongPredicate selector)
withIndexedFilter
in class AbstractParallelAnyArray.LUPap
selector
- the selectorpublic <U> ParallelLongArrayWithMapping<U> withMapping(Ops.LongToObject<? extends U> op)
withMapping
in class AbstractParallelAnyArray.LUPap
op
- the oppublic ParallelLongArrayWithLongMapping withMapping(Ops.LongOp op)
withMapping
in class AbstractParallelAnyArray.LUPap
op
- the oppublic ParallelLongArrayWithDoubleMapping withMapping(Ops.LongToDouble op)
withMapping
in class AbstractParallelAnyArray.LUPap
op
- the oppublic <V,W,X> ParallelLongArrayWithMapping<W> withMapping(Ops.LongAndObjectToObject<? super V,? extends W> combiner, ParallelArrayWithMapping<X,V> other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public <V> ParallelLongArrayWithMapping<V> withMapping(Ops.LongAndDoubleToObject<? extends V> combiner, ParallelDoubleArrayWithDoubleMapping other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public <V> ParallelLongArrayWithMapping<V> withMapping(Ops.LongAndLongToObject<? extends V> combiner, ParallelLongArrayWithLongMapping other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public <V,W> ParallelLongArrayWithDoubleMapping withMapping(Ops.LongAndObjectToDouble<? super V> combiner, ParallelArrayWithMapping<W,V> other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public ParallelLongArrayWithDoubleMapping withMapping(Ops.LongAndDoubleToDouble combiner, ParallelDoubleArrayWithDoubleMapping other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public ParallelLongArrayWithDoubleMapping withMapping(Ops.LongAndLongToDouble combiner, ParallelLongArrayWithLongMapping other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public <V,W> ParallelLongArrayWithLongMapping withMapping(Ops.LongAndObjectToLong<? super V> combiner, ParallelArrayWithMapping<W,V> other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public ParallelLongArrayWithLongMapping withMapping(Ops.LongAndDoubleToLong combiner, ParallelDoubleArrayWithDoubleMapping other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public ParallelLongArrayWithLongMapping withMapping(Ops.BinaryLongOp combiner, ParallelLongArrayWithLongMapping other)
withMapping
in class ParallelLongArrayWithLongMapping
combiner
- the combinerother
- the other arrayjava.lang.IllegalArgumentException
- if other array is a
filtered view (all filters must precede all mappings)public <U> ParallelLongArrayWithMapping<U> withIndexedMapping(Ops.IntAndLongToObject<? extends U> mapper)
withIndexedMapping
in class AbstractParallelAnyArray.LUPap
mapper
- the mapperpublic ParallelLongArrayWithDoubleMapping withIndexedMapping(Ops.IntAndLongToDouble mapper)
withIndexedMapping
in class AbstractParallelAnyArray.LUPap
mapper
- the mapperpublic ParallelLongArrayWithLongMapping withIndexedMapping(Ops.IntAndLongToLong mapper)
withIndexedMapping
in class AbstractParallelAnyArray.LUPap
mapper
- the mapperpublic java.util.Iterator<java.lang.Long> iterator()
ListIterator
supporting add, remove, and set
operations is available via asList()
.public java.util.List<java.lang.Long> asList()
ArrayList
, and may be used to modify, replace or extend the
bounds of the array underlying this ParallelLongArray. The methods
supported by this list view are not in general
implemented as parallel operations. This list is also not
itself thread-safe. In particular, performing list updates
while other parallel operations are in progress has undefined
(and surely undesired) effects.public int size()
setLimit(int)
), or the length of the array otherwise.size
in class AbstractParallelAnyArray
public long[] getArray()
public long get(int i)
i
- the indexpublic void set(int i, long x)
i
- the indexx
- the valuepublic java.lang.String toString()
asList().toString()
.toString
in class java.lang.Object
public final void setLimit(int newLimit)
newLimit
- the new upper boundjava.lang.IllegalArgumentException
- if newLimit less than zerofinal void replaceElementsParallelLongArrayWith(long[] a)
final void resizeArray(int newCap)
final void insertElementAt(int index, long e)
final void appendElement(long e)
final void insertSlotsAt(int index, int len)
final void removeSlotAt(int index)
final void removeSlotsAt(int fromIndex, int toIndex)
final int seqIndexOf(long target)
final int seqLastIndexOf(long target)