jsr166y.forkjoin
Class ParallelLongArray.WithBounds

java.lang.Object
  extended by jsr166y.forkjoin.ParallelLongArray.WithLongMapping
      extended by jsr166y.forkjoin.ParallelLongArray.WithFilter
          extended by jsr166y.forkjoin.ParallelLongArray.WithBounds
Enclosing class:
ParallelLongArray

public static final class ParallelLongArray.WithBounds
extends ParallelLongArray.WithFilter

A restriction of parallel array operations to apply only within a given range of indices.


Method Summary
 ParallelLongArray all()
          Returns a new ParallelLongArray holding elements
 ParallelLongArray allUniqueElements()
          Returns a new ParallelLongArray containing only unique elements (that is, without any duplicates).
 int anyIndex()
          Returns the index of some element matching bound and filter constraints, or -1 if none.
 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.
 ParallelLongArray combine(long[] other, Ops.LongReducer combiner)
          Returns a ParallelLongArray containing results of applying combine(thisElement, otherElement) for each element.
<U,V> ParallelLongArray
combine(ParallelLongArray.WithBounds other, Ops.LongReducer combiner)
          Returns a ParallelLongArray containing results of applying combine(thisElement, otherElement) for each element.
 ParallelLongArray combine(ParallelLongArray other, Ops.LongReducer combiner)
          Returns a ParallelLongArray containing results of applying combine(thisElement, otherElement) for each element.
 void cumulate(Ops.LongReducer reducer, long base)
          Replaces each element with the running cumulation of applying the given reducer.
 void 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
 ParallelLongArray.WithFilter orFilter(Ops.LongPredicate selector)
          Returns an operation prefix that causes a method to operate only on elements for which the current selector (if present) or the given selector returns true
 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
 void removeAll()
          Removes from the array all elements matching bound and/or filter constraints.
 void removeConsecutiveDuplicates()
          Removes consecutive elements that are equal (or null), shifting others leftward, and possibly decreasing size.
 int size()
          Return the number of elements selected using bound or filter restrictions.
 void sort()
          Sorts the elements, assuming all elements are Comparable.
 void sort(Ops.LongComparator cmp)
          Sorts the 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(Ops.LongPredicate selector)
          Returns an operation prefix that causes a method to operate only on elements for which the current selector (if present) and the given selector returns true
 ParallelLongArray.WithLongMapping withMapping(Ops.LongMapper mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
<U> ParallelLongArray.WithMapping<U>
withMapping(Ops.MapperFromLong<? extends U> mapper)
          Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.
 ParallelLongArray.WithDoubleMapping withMapping(Ops.MapperFromLongToDouble 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 jsr166y.forkjoin.ParallelLongArray.WithFilter
replaceWithCombination, replaceWithCombination, replaceWithCombination, replaceWithGeneratedValue, replaceWithMappedIndex, replaceWithTransform, replaceWithValue
 
Methods inherited from class jsr166y.forkjoin.ParallelLongArray.WithLongMapping
apply, max, max, min, min, reduce, sum, summary, summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withBounds

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

withFilter

public ParallelLongArray.WithFilter withFilter(Ops.LongPredicate selector)
Description copied from class: ParallelLongArray.WithFilter
Returns an operation prefix that causes a method to operate only on elements for which the current selector (if present) and the given selector returns true

Specified by:
withFilter in class ParallelLongArray.WithFilter
Parameters:
selector - the selector
Returns:
operation prefix

withMapping

public <U> ParallelLongArray.WithMapping<U> withMapping(Ops.MapperFromLong<? extends U> mapper)
Description copied from class: ParallelLongArray.WithLongMapping
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelLongArray.WithLongMapping
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelLongArray.WithLongMapping withMapping(Ops.LongMapper mapper)
Description copied from class: ParallelLongArray.WithLongMapping
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelLongArray.WithLongMapping
Parameters:
mapper - the mapper
Returns:
operation prefix

withMapping

public ParallelLongArray.WithDoubleMapping withMapping(Ops.MapperFromLongToDouble mapper)
Description copied from class: ParallelLongArray.WithLongMapping
Returns an operation prefix that causes a method to operate on mapped elements of the array using the given mapper.

Specified by:
withMapping in class ParallelLongArray.WithLongMapping
Parameters:
mapper - the mapper
Returns:
operation prefix

orFilter

public ParallelLongArray.WithFilter orFilter(Ops.LongPredicate selector)
Description copied from class: ParallelLongArray.WithFilter
Returns an operation prefix that causes a method to operate only on elements for which the current selector (if present) or the given selector returns true

Specified by:
orFilter in class ParallelLongArray.WithFilter
Parameters:
selector - the selector
Returns:
operation prefix

anyIndex

public int anyIndex()
Description copied from class: ParallelLongArray.WithLongMapping
Returns the index of some element matching bound and filter constraints, or -1 if none.

Specified by:
anyIndex in class ParallelLongArray.WithLongMapping
Returns:
index of matching element, or -1 if none.

combine

public ParallelLongArray combine(long[] other,
                                 Ops.LongReducer combiner)
Returns a ParallelLongArray containing results of applying combine(thisElement, otherElement) for each element.

Parameters:
other - the other array
combiner - the combiner
Returns:
the array of mappings
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other array is shorter than this array.

combine

public ParallelLongArray combine(ParallelLongArray other,
                                 Ops.LongReducer combiner)
Returns a ParallelLongArray containing results of applying combine(thisElement, otherElement) for each element.

Parameters:
other - the other array
combiner - the combiner
Returns:
the array of mappings
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other array is shorter than this array.

combine

public <U,V> ParallelLongArray combine(ParallelLongArray.WithBounds other,
                                       Ops.LongReducer combiner)
Returns a ParallelLongArray containing results of applying combine(thisElement, otherElement) for each element.

Parameters:
other - the other array segment
combiner - the combiner
Returns:
the array of mappings
Throws:
java.lang.ArrayIndexOutOfBoundsException - if other segment is shorter than this array.

all

public ParallelLongArray all()
Description copied from class: ParallelLongArray.WithLongMapping
Returns a new ParallelLongArray holding elements

Specified by:
all in class ParallelLongArray.WithLongMapping
Returns:
a new ParallelLongArray holding elements

allUniqueElements

public ParallelLongArray allUniqueElements()
Description copied from class: ParallelLongArray.WithFilter
Returns a new ParallelLongArray containing only unique elements (that is, without any duplicates).

Specified by:
allUniqueElements in class ParallelLongArray.WithFilter
Returns:
the new ParallelLongArray

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

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

size

public int size()
Description copied from class: ParallelLongArray.WithLongMapping
Return the number of elements selected using bound or filter restrictions. Note that this method must evaluate all selectors to return its result.

Specified by:
size in class ParallelLongArray.WithLongMapping
Returns:
the number of elements

cumulate

public void cumulate(Ops.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

cumulateSum

public void cumulateSum()
Replaces each element with the running sum


precumulate

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

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 void sort(Ops.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

sort

public void 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:
java.lang.ClassCastException - if any element is not Comparable.

removeAll

public void removeAll()
Description copied from class: ParallelLongArray.WithFilter
Removes from the array all elements matching bound and/or filter constraints.

Specified by:
removeAll in class ParallelLongArray.WithFilter

removeConsecutiveDuplicates

public void removeConsecutiveDuplicates()
Removes consecutive elements that are equal (or null), 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.