An array of longs supporting parallel operations. This class
provides methods supporting the same operations as ParallelArray, but specialized for scalar longs. It additionally
provides a few methods specific to numerical values.

createUsingHandoff

Creates a new ParallelLongArray initially using the given array and
executor. In general, the handed off array should not be used
for other purposes once constructing this ParallelLongArray. The
given array may be internally replaced by another array in the
course of methods that add or remove elements.

cumulate

Replaces each element with the running cumulation of applying
the given reducer. For example, if the contents are the numbers
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).

Parameters:

reducer - the reducer

base - the result for an empty array

Returns:

this (to simplify use in expressions)

precumulate

Replaces each element with the cumulation of applying the given
reducer to all previous values, and returns the total
reduction. For example, if the contents are the numbers 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).

removeConsecutiveDuplicates

Removes consecutive elements that are equal,
shifting others leftward, and possibly decreasing size. This
method may be used after sorting to ensure that this
ParallelLongArray contains a set of unique elements.

iterator

Returns an iterator stepping through each element of the array
up to the current limit. This iterator does not
support the remove operation. However, a full
ListIterator supporting add, remove, and set
operations is available via asList().

Returns:

an iterator stepping through each element

asList

Returns a view of this ParallelLongArray as a List. This List has
the same structural and performance characteristics as 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.

Returns:

a list view

size

public int size()

Returns the effective size of the underlying array. The
effective size is the current limit, if used (see setLimit(int)), or the length of the array otherwise.

toString

setLimit

public final 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. Or, if the given limit is less
than the length of the underlying array, causes computations to
ignore elements past the given limit.