org.codehaus.gpars

groovyx.gpars.extra166y
[Java] Class ParallelLongArrayWithBounds

java.lang.Object
  groovyx.gpars.extra166y.AbstractParallelAnyArray.LPap
      groovyx.gpars.extra166y.ParallelLongArrayWithLongMapping
          groovyx.gpars.extra166y.ParallelLongArrayWithFilter
              groovyx.gpars.extra166y.ParallelLongArrayWithBounds

public abstract class ParallelLongArrayWithBounds
extends ParallelLongArrayWithFilter

A prefix view of ParallelLongArray that causes operations to apply only to elements within a given range. Instances of this class may be constructed only via prefix methods of ParallelLongArray or its other prefix classes.


Constructor Summary
ParallelLongArrayWithBounds(ForkJoinPool ex, int origin, int fence, long[] array)

 
Method Summary
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, 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.

ParallelLongArrayWithBounds cumulate(LongReducer reducer, long base)

Replaces each element with the running cumulation of applying the given reducer.

ParallelLongArrayWithBounds cumulateSum()

Replaces each element with the running sum.

int indexOf(long target)

Returns the index of some element equal to given target, or -1 if not present.

long precumulate(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.

ParallelLongArrayWithBounds sort(LongComparator cmp)

Sorts the elements.

ParallelLongArrayWithBounds sort()

Sorts the elements, assuming all elements are Comparable.

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).

 
Methods inherited from class ParallelLongArrayWithFilter
allUniqueElements, hasAllEqualElements, leafTransfer, leafTransferByIndex, lget, replaceWithGeneratedValue, replaceWithMappedIndex, replaceWithMappedIndex, replaceWithMapping, replaceWithMapping, replaceWithMapping, replaceWithValue, withFilter, withFilter, withIndexedFilter
 
Methods inherited from class ParallelLongArrayWithLongMapping
all, apply, max, max, min, min, reduce, sequentially, sum, summary, summary, withIndexedMapping, withIndexedMapping, withIndexedMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping, withMapping
 

Constructor Detail

ParallelLongArrayWithBounds

ParallelLongArrayWithBounds(ForkJoinPool ex, int origin, int fence, long[] array)


 
Method Detail

binarySearch

public int binarySearch(long target)
Assuming this array is sorted, returns the index of an element equal to given target, or -1 if not present. If the array is not sorted, the results are undefined.
Parameters:
target - the element to search for
Returns:
the index or -1 if not present


binarySearch

public int binarySearch(long target, 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. If the array is not sorted, the results are undefined.
Parameters:
target - the element to search for
comparator - the comparator
Returns:
the index or -1 if not present


cumulate

public ParallelLongArrayWithBounds cumulate(LongReducer reducer, long base)
Replaces each element with the running cumulation of applying the given reducer.
Parameters:
reducer - the reducer
base - the result for an empty array
Returns:
this (to simplify use in expressions)


cumulateSum

public ParallelLongArrayWithBounds cumulateSum()
Replaces each element with the running sum.
Returns:
this (to simplify use in expressions)


indexOf

public int indexOf(long target)
Returns the index of some element equal to given target, or -1 if not present.
Parameters:
target - the element to search for
Returns:
the index or -1 if not present


precumulate

public long precumulate(LongReducer reducer, long base)
Replaces each element with the cumulation of applying the given reducer to all previous values, and returns the total reduction.
Parameters:
reducer - the reducer
base - the result for an empty array
Returns:
the total reduction


precumulateSum

public long precumulateSum()
Replaces each element with its prefix sum.
Returns:
the total sum


sort

public ParallelLongArrayWithBounds sort(LongComparator cmp)
Sorts the elements. Unlike Arrays.sort, this sort does not guarantee that elements with equal keys maintain their relative position in the array.
Parameters:
cmp - the comparator to use
Returns:
this (to simplify use in expressions)


sort

public ParallelLongArrayWithBounds sort()
Sorts the elements, assuming all elements are Comparable. Unlike Arrays.sort, this sort does not guarantee that elements with equal keys maintain their relative position in the array.
throws:
ClassCastException if any element is not Comparable
Returns:
this (to simplify use in expressions)


withBounds

public 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). The bound arguments are relative to the current bounds. For example pa.withBounds(2, 8).withBounds(3, 5) indexes the 5th (= 2+3) and 6th elements of pa. However, indices returned by methods such as indexOf are with respect to the underlying ParallelLongArray.
Parameters:
firstIndex - the lower bound (inclusive)
upperBound - the upper bound (exclusive)
Returns:
operation prefix


 

Copyright © 2008–2013 Václav Pech. All Rights Reserved.