ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/extra166y/ParallelLongArrayWithBounds.java
Revision: 1.9
Committed: Thu Feb 26 06:53:34 2015 UTC (9 years, 2 months ago) by jsr166
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +0 -1 lines
Log Message:
delete unused imports

File Contents

# User Rev Content
1 dl 1.1 /*
2     * Written by Doug Lea with assistance from members of JCP JSR-166
3     * Expert Group and released to the public domain, as explained at
4 jsr166 1.2 * http://creativecommons.org/publicdomain/zero/1.0/
5 dl 1.1 */
6    
7     package extra166y;
8 jsr166 1.8
9 dl 1.1 import jsr166y.*;
10     import static extra166y.Ops.*;
11     import java.util.*;
12     import java.util.concurrent.atomic.*;
13    
14     /**
15     * A prefix view of ParallelLongArray that causes operations to apply
16     * only to elements within a given range.
17     * Instances of this class may be constructed only via prefix
18     * methods of ParallelLongArray or its other prefix classes.
19     */
20     public abstract class ParallelLongArrayWithBounds extends ParallelLongArrayWithFilter {
21     ParallelLongArrayWithBounds
22     (ForkJoinPool ex, int origin, int fence, long[] array) {
23     super(ex, origin, fence, array);
24     }
25    
26     /**
27     * Returns an operation prefix that causes a method to operate
28     * only on the elements of the array between firstIndex
29     * (inclusive) and upperBound (exclusive). The bound
30     * arguments are relative to the current bounds. For example
31 jsr166 1.6 * {@code pa.withBounds(2, 8).withBounds(3, 5)} indexes the
32 dl 1.1 * 5th (= 2+3) and 6th elements of pa. However, indices
33 jsr166 1.6 * returned by methods such as {@code indexOf} are
34 dl 1.1 * with respect to the underlying ParallelLongArray.
35     * @param firstIndex the lower bound (inclusive)
36     * @param upperBound the upper bound (exclusive)
37     * @return operation prefix
38     */
39     public abstract ParallelLongArrayWithBounds withBounds
40     (int firstIndex, int upperBound);
41    
42     /**
43     * Returns the index of some element equal to given target, or
44 jsr166 1.4 * -1 if not present.
45 dl 1.1 * @param target the element to search for
46     * @return the index or -1 if not present
47     */
48     public abstract int indexOf(long target);
49    
50     /**
51     * Assuming this array is sorted, returns the index of an
52     * element equal to given target, or -1 if not present. If the
53     * array is not sorted, the results are undefined.
54     * @param target the element to search for
55     * @return the index or -1 if not present
56     */
57     public abstract int binarySearch(long target);
58    
59     /**
60     * Assuming this array is sorted with respect to the given
61     * comparator, returns the index of an element equal to given
62     * target, or -1 if not present. If the array is not sorted,
63     * the results are undefined.
64     * @param target the element to search for
65     * @param comparator the comparator
66     * @return the index or -1 if not present
67     */
68     public abstract int binarySearch(long target, LongComparator comparator);
69    
70     /**
71     * Replaces each element with the running cumulation of applying
72     * the given reducer.
73     * @param reducer the reducer
74     * @param base the result for an empty array
75     * @return this (to simplify use in expressions)
76     */
77     public abstract ParallelLongArrayWithBounds cumulate(LongReducer reducer, long base);
78    
79     /**
80 jsr166 1.4 * Replaces each element with the running sum.
81 dl 1.1 * @return this (to simplify use in expressions)
82     */
83     public abstract ParallelLongArrayWithBounds cumulateSum();
84    
85     /**
86     * Replaces each element with the cumulation of applying the given
87     * reducer to all previous values, and returns the total
88     * reduction.
89     * @param reducer the reducer
90     * @param base the result for an empty array
91     * @return the total reduction
92     */
93     public abstract long precumulate(LongReducer reducer, long base);
94    
95     /**
96 jsr166 1.5 * Replaces each element with its prefix sum.
97 dl 1.1 * @return the total sum
98     */
99     public abstract long precumulateSum();
100    
101     /**
102     * Sorts the elements.
103     * Unlike Arrays.sort, this sort does
104     * not guarantee that elements with equal keys maintain their
105     * relative position in the array.
106     * @param cmp the comparator to use
107     * @return this (to simplify use in expressions)
108     */
109     public abstract ParallelLongArrayWithBounds sort(LongComparator cmp);
110    
111     /**
112     * Sorts the elements, assuming all elements are
113     * Comparable. Unlike Arrays.sort, this sort does not
114     * guarantee that elements with equal keys maintain their relative
115     * position in the array.
116 jsr166 1.7 * @return this (to simplify use in expressions)
117 jsr166 1.4 * @throws ClassCastException if any element is not Comparable
118 dl 1.1 */
119     public abstract ParallelLongArrayWithBounds sort();
120    
121     }