ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/extra166y/Ops.java
(Generate patch)

Comparing jsr166/src/extra166y/Ops.java (file contents):
Revision 1.4 by jsr166, Tue Oct 25 20:29:12 2011 UTC vs.
Revision 1.8 by jsr166, Sun Jan 18 20:17:32 2015 UTC

# Line 5 | Line 5
5   */
6  
7   package extra166y;
8 +
9   import java.util.*;
10  
11   /**
# Line 12 | Line 13 | import java.util.*;
13   * within parallel methods on aggregates. This class provides type
14   * names for all operation signatures accepting zero, one or two
15   * arguments, and returning zero or one results, for parameterized
16 < * types, as well as specializations to <tt>int</tt>, <tt>long</tt>,
17 < * and <tt>double</tt>. In keeping with normal Java evaluation rules
18 < * that promote, for example <tt>short</tt> to <tt>int</tt>, operation
16 > * types, as well as specializations to {@code int}, {@code long},
17 > * and {@code double}. In keeping with normal Java evaluation rules
18 > * that promote, for example {@code short} to {@code int}, operation
19   * names for these smaller types are absent.
20   *
21   * <p><b>Preliminary release note: Some of the declarations in this
# Line 26 | Line 27 | import java.util.*;
27   * <ul>
28   *
29   * <li> The name of the single method declared in each interface is
30 < * simply <tt>op</tt> (short for "operate").
30 > * simply {@code op} (short for "operate").
31   *
32 < * <li> An <tt>Op</tt> (short for "operation") maps a single argument to
32 > * <li> An {@code Op} (short for "operation") maps a single argument to
33   * a result. Example: negating a value.
34   *
35   * <li> The names for scalar ops accepting and returning the same type
36   * are prefaced by their type name.
37   *
38 < * <li> A <tt>BinaryOp</tt> maps two arguments to a result. Example:
38 > * <li> A {@code BinaryOp} maps two arguments to a result. Example:
39   * dividing two numbers
40   *
41 < * <li>A <tt>Reducer</tt> is an <em>associative</em> binary op
41 > * <li>A {@code Reducer} is an <em>associative</em> binary op
42   * accepting and returning values of the same type; where op(a, op(b,
43   * c)) should have the same result as op(op(a, b), c).  Example:
44   * adding two numbers.
# Line 48 | Line 49 | import java.util.*;
49   * <li> Mixed-type operators are named just by their argument type
50   * names.
51   *
52 < * <li> A <tt>Generator</tt> takes no arguments and returns a result.
52 > * <li> A {@code Generator} takes no arguments and returns a result.
53   * Examples: random number generators, builders
54   *
55 < * <li> A <tt>Procedure</tt> accepts an argument but doesn't return a
56 < * result. Example: printing a value.  An <tt>Action</tt> is a
55 > * <li> A {@code Procedure} accepts an argument but doesn't return a
56 > * result. Example: printing a value.  An {@code Action} is a
57   * Procedure that takes no arguments.
58   *
59 < * <li>A <tt>Predicate</tt> accepts a value and returns a boolean indicator
59 > * <li>A {@code Predicate} accepts a value and returns a boolean indicator
60   * that the argument obeys some property. Example: testing if a number is even.
61   *
62 < * <li>A <tt>BinaryPredicate</tt> accepts two values and returns a
62 > * <li>A {@code BinaryPredicate} accepts two values and returns a
63   * boolean indicator that the arguments obeys some relation. Example:
64   * testing if two numbers are relatively prime.
65   *
# Line 88 | Line 89 | import java.util.*;
89   * <td >
90   * <th >a
91   * <th >b
92 < * <th ><tt>int</tt>
93 < * <th ><tt>long</tt>
94 < * <th ><tt>double</tt>
92 > * <th >{@code int}
93 > * <th >{@code long}
94 > * <th >{@code double}
95   * <th >Object
96   * <td >
97   * <tr>
# Line 104 | Line 105 | import java.util.*;
105   * <td >
106   * <tr>
107   * <td >
108 < * <td ><tt>int</tt>
108 > * <td >{@code int}
109   * <td ><em>&lt;none&gt;</em>
110   * <td ><a href="Ops.IntOp.html">Ops.IntOp</a>
111   * <td ><a href="Ops.IntToLong.html">Ops.IntToLong</a>
# Line 114 | Line 115 | import java.util.*;
115   * <tr>
116   * <td >
117   * <td >
118 < * <td ><tt>int</tt>
118 > * <td >{@code int}
119   * <td ><a href="Ops.BinaryIntOp.html">Ops.BinaryIntOp</a>
120   * <td ><a href="Ops.IntAndIntToLong.html">Ops.IntAndIntToLong</a>
121   * <td ><a href="Ops.IntAndIntToDouble.html">Ops.IntAndIntToDouble</a>
# Line 123 | Line 124 | import java.util.*;
124   * <tr>
125   * <td >
126   * <td >
127 < * <td ><tt>long</tt>
127 > * <td >{@code long}
128   * <td ><a href="Ops.IntAndLongToInt.html">Ops.IntAndLongToInt</a>
129   * <td ><a href="Ops.IntAndLongToLong.html">Ops.IntAndLongToLong</a>
130   * <td ><a href="Ops.IntAndLongToDouble.html">Ops.IntAndLongToDouble</a>
# Line 132 | Line 133 | import java.util.*;
133   * <tr>
134   * <td >
135   * <td >
136 < * <td ><tt>double</tt>
136 > * <td >{@code double}
137   * <td ><a href="Ops.IntAndDoubleToInt.html">Ops.IntAndDoubleToInt</a>
138   * <td ><a href="Ops.IntAndDoubleToLong.html">Ops.IntAndDoubleToLong</a>
139   * <td ><a href="Ops.IntAndDoubleToDouble.html">Ops.IntAndDoubleToDouble</a>
# Line 158 | Line 159 | import java.util.*;
159   * <td >
160   * <tr>
161   * <td >
162 < * <td ><tt>long</tt>
162 > * <td >{@code long}
163   * <td ><em>&lt;none&gt;</em>
164   * <td ><a href="Ops.LongToInt.html">Ops.LongToInt</a>
165   * <td ><a href="Ops.LongOp.html">Ops.LongOp</a>
# Line 168 | Line 169 | import java.util.*;
169   * <tr>
170   * <td >
171   * <td >
172 < * <td ><tt>int</tt>
172 > * <td >{@code int}
173   * <td ><a href="Ops.LongAndIntToInt.html">Ops.LongAndIntToInt</a>
174   * <td ><a href="Ops.LongAndIntToLong.html">Ops.LongAndIntToLong</a>
175   * <td ><a href="Ops.LongAndIntToDouble.html">Ops.LongAndIntToDouble</a>
# Line 177 | Line 178 | import java.util.*;
178   * <tr>
179   * <td >
180   * <td >
181 < * <td ><tt>long</tt>
181 > * <td >{@code long}
182   * <td ><a href="Ops.LongAndLongToInt.html">Ops.LongAndLongToInt</a>
183   * <td ><a href="Ops.BinaryLongOp.html">Ops.BinaryLongOp</a>
184   * <td ><a href="Ops.LongAndLongToDouble.html">Ops.LongAndLongToDouble</a>
# Line 186 | Line 187 | import java.util.*;
187   * <tr>
188   * <td >
189   * <td >
190 < * <td ><tt>double</tt>
190 > * <td >{@code double}
191   * <td ><a href="Ops.LongAndDoubleToInt.html">Ops.LongAndDoubleToInt</a>
192   * <td ><a href="Ops.LongAndDoubleToLong.html">Ops.LongAndDoubleToLong</a>
193   * <td ><a href="Ops.LongAndDoubleToDouble.html">Ops.LongAndDoubleToDouble</a>
# Line 212 | Line 213 | import java.util.*;
213   * <td >
214   * <tr>
215   * <td >
216 < * <td ><tt>double</tt>
216 > * <td >{@code double}
217   * <td ><em>&lt;none&gt;</em>
218   * <td ><a href="Ops.DoubleToInt.html">Ops.DoubleToInt</a>
219   * <td ><a href="Ops.DoubleToLong.html">Ops.DoubleToLong</a>
# Line 222 | Line 223 | import java.util.*;
223   * <tr>
224   * <td >
225   * <td >
226 < * <td ><tt>int</tt>
226 > * <td >{@code int}
227   * <td ><a href="Ops.DoubleAndIntToInt.html">Ops.DoubleAndIntToInt</a>
228   * <td ><a href="Ops.DoubleAndIntToLong.html">Ops.DoubleAndIntToLong</a>
229   * <td ><a href="Ops.DoubleAndIntToDouble.html">Ops.DoubleAndIntToDouble</a>
# Line 231 | Line 232 | import java.util.*;
232   * <tr>
233   * <td >
234   * <td >
235 < * <td ><tt>long</tt>
235 > * <td >{@code long}
236   * <td ><a href="Ops.DoubleAndLongToInt.html">Ops.DoubleAndLongToInt</a>
237   * <td ><a href="Ops.DoubleAndLongToLong.html">Ops.DoubleAndLongToLong</a>
238   * <td ><a href="Ops.DoubleAndLongToDouble.html">Ops.DoubleAndLongToDouble</a>
# Line 240 | Line 241 | import java.util.*;
241   * <tr>
242   * <td >
243   * <td >
244 < * <td ><tt>double</tt>
244 > * <td >{@code double}
245   * <td ><a href="Ops.DoubleAndDoubleToInt.html">Ops.DoubleAndDoubleToInt</a>
246   * <td ><a href="Ops.DoubleAndDoubleToLong.html">Ops.DoubleAndDoubleToLong</a>
247   * <td ><a href="Ops.BinaryDoubleOp.html">Ops.BinaryDoubleOp</a>
# Line 275 | Line 276 | import java.util.*;
276   * <tr>
277   * <td >
278   * <td >
279 < * <td ><tt>int</tt>
279 > * <td >{@code int}
280   * <td ><a href="Ops.ObjectAndIntToInt.html">Ops.ObjectAndIntToInt</a>
281   * <td ><a href="Ops.ObjectAndIntToLong.html">Ops.ObjectAndIntToLong</a>
282   * <td ><a href="Ops.ObjectAndIntToDouble.html">Ops.ObjectAndIntToDouble</a>
# Line 284 | Line 285 | import java.util.*;
285   * <tr>
286   * <td >
287   * <td >
288 < * <td ><tt>long</tt>
288 > * <td >{@code long}
289   * <td ><a href="Ops.ObjectAndLongToInt.html">Ops.ObjectAndLongToInt</a>
290   * <td ><a href="Ops.ObjectAndLongToLong.html">Ops.ObjectAndLongToLong</a>
291   * <td ><a href="Ops.ObjectAndLongToDouble.html">Ops.ObjectAndLongToDouble</a>
# Line 293 | Line 294 | import java.util.*;
294   * <tr>
295   * <td >
296   * <td >
297 < * <td ><tt>double</tt>
297 > * <td >{@code double}
298   * <td ><a href="Ops.ObjectAndDoubleToInt.html">Ops.ObjectAndDoubleToInt</a>
299   * <td ><a href="Ops.ObjectAndDoubleToLong.html">Ops.ObjectAndDoubleToLong</a>
300   * <td ><a href="Ops.ObjectAndDoubleToDouble.html">Ops.ObjectAndDoubleToDouble</a>
# Line 325 | Line 326 | import java.util.*;
326   * constructions. Additionally, they should not block waiting for
327   * synchronization.
328   *
329 < * <p>This class is normally best used via <tt>import static</tt>.
329 > * <p>This class is normally best used via {@code import static}.
330   */
331   public class Ops {
332      private Ops() {} // disable construction
# Line 339 | Line 340 | public class Ops {
340      public static interface BinaryPredicate<A,B>         { boolean op(A a, B b);}
341      public static interface Procedure<A>                 { void    op(A a);}
342      public static interface Generator<R>                 { R       op();}
343 <    public static interface Reducer<A> extends BinaryOp<A, A, A>{}
343 >    public static interface Reducer<A> extends BinaryOp<A,A,A> {}
344  
345      public static interface IntOp                        { int     op(int a);}
346      public static interface BinaryIntOp                  { int     op(int a, int b);}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines