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 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
18 |
|
private CommonOps() {} // disable construction |
19 |
|
|
20 |
|
/** |
21 |
< |
* Returns a Comparator for Comparable objects |
21 |
> |
* Returns a Comparator for Comparable objects. |
22 |
|
*/ |
23 |
|
public static <T extends Comparable<? super T>> Comparator<T> |
24 |
|
naturalComparator(Class<T> type) { |
36 |
|
return new Reducer<T>() { |
37 |
|
public T op(T a, T b) { |
38 |
|
return (a != null && |
39 |
< |
(b == null || a.compareTo(b) >= 0))? a : b; |
39 |
> |
(b == null || a.compareTo(b) >= 0)) ? a : b; |
40 |
|
} |
41 |
|
}; |
42 |
|
} |
50 |
|
return new Reducer<T>() { |
51 |
|
public T op(T a, T b) { |
52 |
|
return (a != null && |
53 |
< |
(b == null || a.compareTo(b) <= 0))? a : b; |
53 |
> |
(b == null || a.compareTo(b) <= 0)) ? a : b; |
54 |
|
} |
55 |
|
}; |
56 |
|
} |
65 |
|
return new Reducer<T>() { |
66 |
|
public T op(T a, T b) { |
67 |
|
return (a != null && |
68 |
< |
(b == null || comparator.compare(a, b) >= 0))? a : b; |
68 |
> |
(b == null || comparator.compare(a, b) >= 0)) ? a : b; |
69 |
|
} |
70 |
|
}; |
71 |
|
} |
80 |
|
return new Reducer<T>() { |
81 |
|
public T op(T a, T b) { |
82 |
|
return (a != null && |
83 |
< |
(b == null || comparator.compare(a, b) <= 0))? a : b; |
83 |
> |
(b == null || comparator.compare(a, b) <= 0)) ? a : b; |
84 |
|
} |
85 |
|
}; |
86 |
|
} |
101 |
|
|
102 |
|
/** |
103 |
|
* Returns a reducer returning maximum of two values, or |
104 |
< |
* <tt>null</tt> if both arguments are null, and that casts |
104 |
> |
* {@code null} if both arguments are null, and that casts |
105 |
|
* its arguments as Comparable on each comparison, throwing |
106 |
|
* ClassCastException on failure. |
107 |
|
*/ |
113 |
|
public Object op(Object a, Object b) { |
114 |
|
return (a != null && |
115 |
|
(b == null || |
116 |
< |
((Comparable)a).compareTo((Comparable)b) >= 0))? a : b; |
116 |
> |
((Comparable)a).compareTo((Comparable)b) >= 0)) ? a : b; |
117 |
|
} |
118 |
|
} |
119 |
|
|
120 |
|
/** |
121 |
|
* Returns a reducer returning minimum of two values, or |
122 |
< |
* <tt>null</tt> if both arguments are null, and that casts |
122 |
> |
* {@code null} if both arguments are null, and that casts |
123 |
|
* its arguments as Comparable on each comparison, throwing |
124 |
|
* ClassCastException on failure. |
125 |
|
*/ |
131 |
|
public Object op(Object a, Object b) { |
132 |
|
return (a != null && |
133 |
|
(b == null || |
134 |
< |
((Comparable)a).compareTo((Comparable)b) <= 0))? a : b; |
134 |
> |
((Comparable)a).compareTo((Comparable)b) <= 0)) ? a : b; |
135 |
|
} |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
/** |
140 |
< |
* Returns a comparator for doubles relying on natural ordering |
140 |
> |
* Returns a comparator for doubles relying on natural ordering. |
141 |
|
*/ |
142 |
|
public static DoubleComparator naturalDoubleComparator() { |
143 |
|
return NaturalDoubleComparator.comparator; |
153 |
|
|
154 |
|
/** |
155 |
|
* Returns a reducer returning the maximum of two double elements, |
156 |
< |
* using natural comparator |
156 |
> |
* using natural comparator. |
157 |
|
*/ |
158 |
|
public static DoubleReducer naturalDoubleMaxReducer() { |
159 |
|
return NaturalDoubleMaxReducer.max; |
168 |
|
|
169 |
|
/** |
170 |
|
* Returns a reducer returning the minimum of two double elements, |
171 |
< |
* using natural comparator |
171 |
> |
* using natural comparator. |
172 |
|
*/ |
173 |
|
public static DoubleReducer naturalDoubleMinReducer() { |
174 |
|
return NaturalDoubleMinReducer.min; |
182 |
|
|
183 |
|
/** |
184 |
|
* Returns a reducer returning the maximum of two double elements, |
185 |
< |
* using the given comparator |
185 |
> |
* using the given comparator. |
186 |
|
*/ |
187 |
|
public static DoubleReducer doubleMaxReducer |
188 |
|
(final DoubleComparator comparator) { |
189 |
|
return new DoubleReducer() { |
190 |
|
public double op(double a, double b) { |
191 |
< |
return (comparator.compare(a, b) >= 0)? a : b; |
191 |
> |
return (comparator.compare(a, b) >= 0) ? a : b; |
192 |
|
} |
193 |
|
}; |
194 |
|
} |
195 |
|
|
196 |
|
/** |
197 |
|
* Returns a reducer returning the minimum of two double elements, |
198 |
< |
* using the given comparator |
198 |
> |
* using the given comparator. |
199 |
|
*/ |
200 |
|
public static DoubleReducer doubleMinReducer |
201 |
|
(final DoubleComparator comparator) { |
202 |
|
return new DoubleReducer() { |
203 |
|
public double op(double a, double b) { |
204 |
< |
return (comparator.compare(a, b) <= 0)? a : b; |
204 |
> |
return (comparator.compare(a, b) <= 0) ? a : b; |
205 |
|
} |
206 |
|
}; |
207 |
|
} |
208 |
|
|
209 |
|
/** |
210 |
< |
* Returns a comparator for longs relying on natural ordering |
210 |
> |
* Returns a comparator for longs relying on natural ordering. |
211 |
|
*/ |
212 |
|
public static LongComparator naturalLongComparator() { |
213 |
|
return NaturalLongComparator.comparator; |
217 |
|
static final NaturalLongComparator comparator = new |
218 |
|
NaturalLongComparator(); |
219 |
|
public int compare(long a, long b) { |
220 |
< |
return a < b? -1 : ((a > b)? 1 : 0); |
220 |
> |
return (a < b) ? -1 : ((a > b) ? 1 : 0); |
221 |
|
} |
222 |
|
} |
223 |
|
|
224 |
|
/** |
225 |
|
* Returns a reducer returning the maximum of two long elements, |
226 |
< |
* using natural comparator |
226 |
> |
* using natural comparator. |
227 |
|
*/ |
228 |
|
public static LongReducer naturalLongMaxReducer() { |
229 |
|
return NaturalLongMaxReducer.max; |
233 |
|
implements LongReducer { |
234 |
|
public static final NaturalLongMaxReducer max = |
235 |
|
new NaturalLongMaxReducer(); |
236 |
< |
public long op(long a, long b) { return a >= b? a : b; } |
236 |
> |
public long op(long a, long b) { return (a >= b) ? a : b; } |
237 |
|
} |
238 |
|
|
239 |
|
/** |
240 |
|
* A reducer returning the minimum of two long elements, |
241 |
< |
* using natural comparator |
241 |
> |
* using natural comparator. |
242 |
|
*/ |
243 |
|
public static LongReducer naturalLongMinReducer() { |
244 |
|
return NaturalLongMinReducer.min; |
247 |
|
implements LongReducer { |
248 |
|
public static final NaturalLongMinReducer min = |
249 |
|
new NaturalLongMinReducer(); |
250 |
< |
public long op(long a, long b) { return a <= b? a : b; } |
250 |
> |
public long op(long a, long b) { return (a <= b) ? a : b; } |
251 |
|
} |
252 |
|
|
253 |
|
/** |
254 |
|
* Returns a reducer returning the maximum of two long elements, |
255 |
< |
* using the given comparator |
255 |
> |
* using the given comparator. |
256 |
|
*/ |
257 |
|
public static LongReducer longMaxReducer |
258 |
|
(final LongComparator comparator) { |
259 |
|
return new LongReducer() { |
260 |
|
public long op(long a, long b) { |
261 |
< |
return (comparator.compare(a, b) >= 0)? a : b; |
261 |
> |
return (comparator.compare(a, b) >= 0) ? a : b; |
262 |
|
} |
263 |
|
}; |
264 |
|
} |
265 |
|
|
266 |
|
/** |
267 |
|
* Returns a reducer returning the minimum of two long elements, |
268 |
< |
* using the given comparator |
268 |
> |
* using the given comparator. |
269 |
|
*/ |
270 |
|
public static LongReducer longMinReducer |
271 |
|
(final LongComparator comparator) { |
272 |
|
return new LongReducer() { |
273 |
|
public long op(long a, long b) { |
274 |
< |
return (comparator.compare(a, b) <= 0)? a : b; |
274 |
> |
return (comparator.compare(a, b) <= 0) ? a : b; |
275 |
|
} |
276 |
|
}; |
277 |
|
} |
278 |
|
|
279 |
|
/** |
280 |
|
* Returns a composite mapper that applies a second mapper to the results |
281 |
< |
* of applying the first one |
281 |
> |
* of applying the first one. |
282 |
|
*/ |
283 |
|
public static <T,U,V> Op<T,V> compoundOp |
284 |
|
(final Op<? super T, ? extends U> first, |
290 |
|
|
291 |
|
/** |
292 |
|
* Returns a composite mapper that applies a second mapper to the results |
293 |
< |
* of applying the first one |
293 |
> |
* of applying the first one. |
294 |
|
*/ |
295 |
|
public static <T,V> Op<T,V> compoundOp |
296 |
|
(final ObjectToDouble<? super T> first, |
302 |
|
|
303 |
|
/** |
304 |
|
* Returns a composite mapper that applies a second mapper to the results |
305 |
< |
* of applying the first one |
305 |
> |
* of applying the first one. |
306 |
|
*/ |
307 |
|
public static <T,V> Op<T,V> compoundOp |
308 |
|
(final ObjectToLong<? super T> first, |
314 |
|
|
315 |
|
/** |
316 |
|
* Returns a composite mapper that applies a second mapper to the results |
317 |
< |
* of applying the first one |
317 |
> |
* of applying the first one. |
318 |
|
*/ |
319 |
|
public static <T,V> DoubleToObject<V> compoundOp |
320 |
|
(final DoubleToObject<? extends T> first, |
326 |
|
|
327 |
|
/** |
328 |
|
* Returns a composite mapper that applies a second mapper to the results |
329 |
< |
* of applying the first one |
329 |
> |
* of applying the first one. |
330 |
|
*/ |
331 |
|
public static <T,V> LongToObject<V> compoundOp |
332 |
|
(final LongToObject<? extends T> first, |
338 |
|
|
339 |
|
/** |
340 |
|
* Returns a composite mapper that applies a second mapper to the results |
341 |
< |
* of applying the first one |
341 |
> |
* of applying the first one. |
342 |
|
*/ |
343 |
|
public static <T,U> ObjectToDouble<T> compoundOp |
344 |
|
(final Op<? super T, ? extends U> first, |
350 |
|
|
351 |
|
/** |
352 |
|
* Returns a composite mapper that applies a second mapper to the results |
353 |
< |
* of applying the first one |
353 |
> |
* of applying the first one. |
354 |
|
*/ |
355 |
|
public static <T,U> ObjectToLong<T> compoundOp |
356 |
|
(final Op<? super T, ? extends U> first, |
362 |
|
|
363 |
|
/** |
364 |
|
* Returns a composite mapper that applies a second mapper to the results |
365 |
< |
* of applying the first one |
365 |
> |
* of applying the first one. |
366 |
|
*/ |
367 |
|
public static <T> ObjectToDouble<T> compoundOp |
368 |
|
(final ObjectToDouble<? super T> first, |
374 |
|
|
375 |
|
/** |
376 |
|
* Returns a composite mapper that applies a second mapper to the results |
377 |
< |
* of applying the first one |
377 |
> |
* of applying the first one. |
378 |
|
*/ |
379 |
|
public static <T> ObjectToLong<T> compoundOp |
380 |
|
(final ObjectToDouble<? super T> first, |
386 |
|
|
387 |
|
/** |
388 |
|
* Returns a composite mapper that applies a second mapper to the results |
389 |
< |
* of applying the first one |
389 |
> |
* of applying the first one. |
390 |
|
*/ |
391 |
|
public static <T> ObjectToLong<T> compoundOp |
392 |
|
(final ObjectToLong<? super T> first, |
398 |
|
|
399 |
|
/** |
400 |
|
* Returns a composite mapper that applies a second mapper to the results |
401 |
< |
* of applying the first one |
401 |
> |
* of applying the first one. |
402 |
|
*/ |
403 |
|
public static <T> ObjectToDouble<T> compoundOp |
404 |
|
(final ObjectToLong<? super T> first, |
410 |
|
|
411 |
|
/** |
412 |
|
* Returns a composite mapper that applies a second mapper to the results |
413 |
< |
* of applying the first one |
413 |
> |
* of applying the first one. |
414 |
|
*/ |
415 |
|
public static DoubleOp compoundOp |
416 |
|
(final DoubleOp first, |
422 |
|
|
423 |
|
/** |
424 |
|
* Returns a composite mapper that applies a second mapper to the results |
425 |
< |
* of applying the first one |
425 |
> |
* of applying the first one. |
426 |
|
*/ |
427 |
|
public static DoubleToLong compoundOp |
428 |
|
(final DoubleOp first, |
434 |
|
|
435 |
|
/** |
436 |
|
* Returns a composite mapper that applies a second mapper to the results |
437 |
< |
* of applying the first one |
437 |
> |
* of applying the first one. |
438 |
|
*/ |
439 |
|
public static DoubleToLong compoundOp |
440 |
|
(final DoubleToLong first, |
446 |
|
|
447 |
|
/** |
448 |
|
* Returns a composite mapper that applies a second mapper to the results |
449 |
< |
* of applying the first one |
449 |
> |
* of applying the first one. |
450 |
|
*/ |
451 |
|
public static <T> DoubleToObject<T> compoundOp |
452 |
|
(final DoubleToLong first, |
458 |
|
|
459 |
|
/** |
460 |
|
* Returns a composite mapper that applies a second mapper to the results |
461 |
< |
* of applying the first one |
461 |
> |
* of applying the first one. |
462 |
|
*/ |
463 |
|
public static <T> LongToObject<T> compoundOp |
464 |
|
(final LongToDouble first, |
470 |
|
|
471 |
|
/** |
472 |
|
* Returns a composite mapper that applies a second mapper to the results |
473 |
< |
* of applying the first one |
473 |
> |
* of applying the first one. |
474 |
|
*/ |
475 |
|
public static LongToDouble compoundOp |
476 |
|
(final LongOp first, |
482 |
|
|
483 |
|
/** |
484 |
|
* Returns a composite mapper that applies a second mapper to the results |
485 |
< |
* of applying the first one |
485 |
> |
* of applying the first one. |
486 |
|
*/ |
487 |
|
public static LongToDouble compoundOp |
488 |
|
(final LongToDouble first, |
494 |
|
|
495 |
|
/** |
496 |
|
* Returns a composite mapper that applies a second mapper to the results |
497 |
< |
* of applying the first one |
497 |
> |
* of applying the first one. |
498 |
|
*/ |
499 |
|
public static <T> DoubleToObject<T> compoundOp |
500 |
|
(final DoubleOp first, |
506 |
|
|
507 |
|
/** |
508 |
|
* Returns a composite mapper that applies a second mapper to the results |
509 |
< |
* of applying the first one |
509 |
> |
* of applying the first one. |
510 |
|
*/ |
511 |
|
public static <T> LongToObject<T> compoundOp |
512 |
|
(final LongOp first, |
518 |
|
|
519 |
|
/** |
520 |
|
* Returns a composite mapper that applies a second mapper to the results |
521 |
< |
* of applying the first one |
521 |
> |
* of applying the first one. |
522 |
|
*/ |
523 |
|
public static <T> DoubleOp compoundOp |
524 |
|
(final DoubleToObject<? extends T> first, |
525 |
< |
final ObjectToDouble<? super T> second) { |
525 |
> |
final ObjectToDouble<? super T> second) { |
526 |
|
return new DoubleOp() { |
527 |
|
public final double op(double t) { return second.op(first.op(t)); } |
528 |
|
}; |
530 |
|
|
531 |
|
/** |
532 |
|
* Returns a composite mapper that applies a second mapper to the results |
533 |
< |
* of applying the first one |
533 |
> |
* of applying the first one. |
534 |
|
*/ |
535 |
|
public static <T> LongToDouble compoundOp |
536 |
|
(final LongToObject<? extends T> first, |
537 |
< |
final ObjectToDouble<? super T> second) { |
537 |
> |
final ObjectToDouble<? super T> second) { |
538 |
|
return new LongToDouble() { |
539 |
|
public final double op(long t) { return second.op(first.op(t)); } |
540 |
|
}; |
542 |
|
|
543 |
|
/** |
544 |
|
* Returns a composite mapper that applies a second mapper to the results |
545 |
< |
* of applying the first one |
545 |
> |
* of applying the first one. |
546 |
|
*/ |
547 |
|
public static <T> DoubleToLong compoundOp |
548 |
|
(final DoubleToObject<? extends T> first, |
549 |
< |
final ObjectToLong<? super T> second) { |
549 |
> |
final ObjectToLong<? super T> second) { |
550 |
|
return new DoubleToLong() { |
551 |
|
public final long op(double t) { return second.op(first.op(t)); } |
552 |
|
}; |
554 |
|
|
555 |
|
/** |
556 |
|
* Returns a composite mapper that applies a second mapper to the results |
557 |
< |
* of applying the first one |
557 |
> |
* of applying the first one. |
558 |
|
*/ |
559 |
|
public static <T> LongOp compoundOp |
560 |
|
(final LongToObject<? extends T> first, |
561 |
< |
final ObjectToLong<? super T> second) { |
561 |
> |
final ObjectToLong<? super T> second) { |
562 |
|
return new LongOp() { |
563 |
|
public final long op(long t) { return second.op(first.op(t)); } |
564 |
|
}; |
566 |
|
|
567 |
|
/** |
568 |
|
* Returns a composite mapper that applies a second mapper to the results |
569 |
< |
* of applying the first one |
569 |
> |
* of applying the first one. |
570 |
|
*/ |
571 |
|
public static LongOp compoundOp |
572 |
|
(final LongOp first, |
578 |
|
|
579 |
|
/** |
580 |
|
* Returns a composite mapper that applies a second mapper to the results |
581 |
< |
* of applying the first one |
581 |
> |
* of applying the first one. |
582 |
|
*/ |
583 |
|
public static DoubleOp compoundOp |
584 |
|
(final DoubleToLong first, |
590 |
|
|
591 |
|
/** |
592 |
|
* Returns a composite mapper that applies a second mapper to the results |
593 |
< |
* of applying the first one |
593 |
> |
* of applying the first one. |
594 |
|
*/ |
595 |
|
public static LongOp compoundOp |
596 |
|
(final LongToDouble first, |
601 |
|
} |
602 |
|
|
603 |
|
/** |
604 |
< |
* Returns a predicate evaluating to the negation of its contained predicate |
604 |
> |
* Returns a predicate evaluating to the negation of its contained predicate. |
605 |
|
*/ |
606 |
|
public static <T> Predicate<T> notPredicate |
607 |
|
(final Predicate<T> pred) { |
611 |
|
} |
612 |
|
|
613 |
|
/** |
614 |
< |
* Returns a predicate evaluating to the negation of its contained predicate |
614 |
> |
* Returns a predicate evaluating to the negation of its contained predicate. |
615 |
|
*/ |
616 |
|
public static DoublePredicate notPredicate |
617 |
|
(final DoublePredicate pred) { |
621 |
|
} |
622 |
|
|
623 |
|
/** |
624 |
< |
* Returns a predicate evaluating to the negation of its contained predicate |
624 |
> |
* Returns a predicate evaluating to the negation of its contained predicate. |
625 |
|
*/ |
626 |
|
public static LongPredicate notPredicate |
627 |
|
(final LongPredicate pred) { |
631 |
|
} |
632 |
|
|
633 |
|
/** |
634 |
< |
* Returns a predicate evaluating to the conjunction of its contained predicates |
634 |
> |
* Returns a predicate evaluating to the conjunction of its contained predicates. |
635 |
|
*/ |
636 |
|
public static <S, T extends S> Predicate<T> andPredicate |
637 |
|
(final Predicate<S> first, |
644 |
|
} |
645 |
|
|
646 |
|
/** |
647 |
< |
* Returns a predicate evaluating to the disjunction of its contained predicates |
647 |
> |
* Returns a predicate evaluating to the disjunction of its contained predicates. |
648 |
|
*/ |
649 |
|
public static <S, T extends S> Predicate<T> orPredicate |
650 |
|
(final Predicate<S> first, |
657 |
|
} |
658 |
|
|
659 |
|
/** |
660 |
< |
* Returns a predicate evaluating to the conjunction of its contained predicates |
660 |
> |
* Returns a predicate evaluating to the conjunction of its contained predicates. |
661 |
|
*/ |
662 |
|
public static DoublePredicate andPredicate |
663 |
|
(final DoublePredicate first, |
670 |
|
} |
671 |
|
|
672 |
|
/** |
673 |
< |
* Returns a predicate evaluating to the disjunction of its contained predicates |
673 |
> |
* Returns a predicate evaluating to the disjunction of its contained predicates. |
674 |
|
*/ |
675 |
|
public static DoublePredicate orPredicate |
676 |
|
(final DoublePredicate first, |
684 |
|
|
685 |
|
|
686 |
|
/** |
687 |
< |
* Returns a predicate evaluating to the conjunction of its contained predicates |
687 |
> |
* Returns a predicate evaluating to the conjunction of its contained predicates. |
688 |
|
*/ |
689 |
|
public static LongPredicate andPredicate |
690 |
|
(final LongPredicate first, |
697 |
|
} |
698 |
|
|
699 |
|
/** |
700 |
< |
* Returns a predicate evaluating to the disjunction of its contained predicates |
700 |
> |
* Returns a predicate evaluating to the disjunction of its contained predicates. |
701 |
|
*/ |
702 |
|
public static LongPredicate orPredicate |
703 |
|
(final LongPredicate first, |
710 |
|
} |
711 |
|
|
712 |
|
/** |
713 |
< |
* Returns a predicate evaluating to true if its argument is non-null |
713 |
> |
* Returns a predicate evaluating to true if its argument is non-null. |
714 |
|
*/ |
715 |
< |
public static Predicate<Object> isNonNullPredicate() { |
715 |
> |
public static Predicate<Object> isNonNullPredicate() { |
716 |
|
return IsNonNullPredicate.predicate; |
717 |
|
} |
718 |
|
static final class IsNonNullPredicate implements Predicate<Object> { |
724 |
|
} |
725 |
|
|
726 |
|
/** |
727 |
< |
* Returns a predicate evaluating to true if its argument is null |
727 |
> |
* Returns a predicate evaluating to true if its argument is null. |
728 |
|
*/ |
729 |
< |
public static Predicate<Object> isNullPredicate() { |
729 |
> |
public static Predicate<Object> isNullPredicate() { |
730 |
|
return IsNullPredicate.predicate; |
731 |
|
} |
732 |
|
static final class IsNullPredicate implements Predicate<Object> { |
762 |
|
} |
763 |
|
|
764 |
|
/** |
765 |
< |
* Returns a reducer that adds two double elements |
765 |
> |
* Returns a reducer that adds two double elements. |
766 |
|
*/ |
767 |
|
public static DoubleReducer doubleAdder() { return DoubleAdder.adder; } |
768 |
|
static final class DoubleAdder implements DoubleReducer { |
771 |
|
} |
772 |
|
|
773 |
|
/** |
774 |
< |
* Returns a reducer that adds two long elements |
774 |
> |
* Returns a reducer that adds two long elements. |
775 |
|
*/ |
776 |
|
public static LongReducer longAdder() { return LongAdder.adder; } |
777 |
|
static final class LongAdder implements LongReducer { |
780 |
|
} |
781 |
|
|
782 |
|
/** |
783 |
< |
* Returns a reducer that adds two int elements |
783 |
> |
* Returns a reducer that adds two int elements. |
784 |
|
*/ |
785 |
|
public static IntReducer intAdder() { return IntAdder.adder; } |
786 |
|
static final class IntAdder implements IntReducer { |
791 |
|
/** |
792 |
|
* Returns a generator producing uniform random values between |
793 |
|
* zero and one, with the same properties as {@link |
794 |
< |
* java.util.Random#nextDouble} |
794 |
> |
* java.util.Random#nextDouble}. |
795 |
|
*/ |
796 |
|
public static DoubleGenerator doubleRandom() { |
797 |
|
return DoubleRandomGenerator.generator; |
823 |
|
|
824 |
|
/** |
825 |
|
* Returns a generator producing uniform random values between the |
826 |
< |
* given least value (inclusive) and bound (exclusive) |
826 |
> |
* given least value (inclusive) and bound (exclusive). |
827 |
|
* @param least the least value returned |
828 |
|
* @param bound the upper bound (exclusive) of opd values |
829 |
|
*/ |
843 |
|
|
844 |
|
/** |
845 |
|
* Returns a generator producing uniform random values with the |
846 |
< |
* same properties as {@link java.util.Random#nextLong} |
846 |
> |
* same properties as {@link java.util.Random#nextLong}. |
847 |
|
*/ |
848 |
|
public static LongGenerator longRandom() { |
849 |
|
return LongRandomGenerator.generator; |
858 |
|
|
859 |
|
/** |
860 |
|
* Returns a generator producing uniform random values with the |
861 |
< |
* same properties as {@link java.util.Random#nextInt(int)} |
861 |
> |
* same properties as {@link java.util.Random#nextInt(int)}. |
862 |
|
* @param bound the upper bound (exclusive) of opd values |
863 |
|
*/ |
864 |
|
public static LongGenerator longRandom(long bound) { |
898 |
|
|
899 |
|
/** |
900 |
|
* Returns a generator producing uniform random values with the |
901 |
< |
* same properties as {@link java.util.Random#nextInt} |
901 |
> |
* same properties as {@link java.util.Random#nextInt}. |
902 |
|
*/ |
903 |
|
public static IntGenerator intRandom() { |
904 |
|
return IntRandomGenerator.generator; |
913 |
|
|
914 |
|
/** |
915 |
|
* Returns a generator producing uniform random values with the |
916 |
< |
* same properties as {@link java.util.Random#nextInt(int)} |
916 |
> |
* same properties as {@link java.util.Random#nextInt(int)}. |
917 |
|
* @param bound the upper bound (exclusive) of opd values |
918 |
|
*/ |
919 |
|
public static IntGenerator intRandom(int bound) { |
931 |
|
|
932 |
|
/** |
933 |
|
* Returns a generator producing uniform random values between the |
934 |
< |
* given least value (inclusive) and bound (exclusive) |
934 |
> |
* given least value (inclusive) and bound (exclusive). |
935 |
|
* @param least the least value returned |
936 |
|
* @param bound the upper bound (exclusive) of opd values |
937 |
|
*/ |
953 |
|
|
954 |
|
/** |
955 |
|
* Returns a predicate evaluating to true if the |
956 |
< |
* first argument <tt>equals</tt> the second |
956 |
> |
* first argument {@code equals} the second. |
957 |
|
*/ |
958 |
|
public static BinaryPredicate<Object, Object> equalityPredicate() { |
959 |
|
return EqualityPredicate.predicate; |
968 |
|
|
969 |
|
/** |
970 |
|
* Returns a predicate evaluating to true if the |
971 |
< |
* first argument <tt>==</tt> the second |
971 |
> |
* first argument {@code ==} the second. |
972 |
|
*/ |
973 |
|
public static BinaryPredicate<Object, Object> identityPredicate() { |
974 |
|
return IdentityPredicate.predicate; |
983 |
|
|
984 |
|
/** |
985 |
|
* Returns a predicate evaluating to true if the |
986 |
< |
* first argument <tt>==</tt> the second |
986 |
> |
* first argument {@code ==} the second. |
987 |
|
*/ |
988 |
|
public static BinaryIntPredicate intEqualityPredicate() { |
989 |
|
return IntEqualityPredicate.predicate; |
998 |
|
|
999 |
|
/** |
1000 |
|
* Returns a predicate evaluating to true if the |
1001 |
< |
* first argument <tt>==</tt> the second |
1001 |
> |
* first argument {@code ==} the second. |
1002 |
|
*/ |
1003 |
|
public static BinaryLongPredicate longEqualityPredicate() { |
1004 |
|
return LongEqualityPredicate.predicate; |
1013 |
|
|
1014 |
|
/** |
1015 |
|
* Returns a predicate evaluating to true if the |
1016 |
< |
* first argument <tt>==</tt> the second |
1016 |
> |
* first argument {@code ==} the second. |
1017 |
|
*/ |
1018 |
|
public static BinaryDoublePredicate doubleEqualityPredicate() { |
1019 |
|
return DoubleEqualityPredicate.predicate; |
1029 |
|
|
1030 |
|
/** |
1031 |
|
* Returns a predicate evaluating to true if the |
1032 |
< |
* first argument <tt>!equals</tt> the second |
1032 |
> |
* first argument {@code !equals} the second. |
1033 |
|
*/ |
1034 |
|
public static BinaryPredicate<Object, Object> inequalityPredicate() { |
1035 |
|
return InequalityPredicate.predicate; |
1044 |
|
|
1045 |
|
/** |
1046 |
|
* Returns a predicate evaluating to true if the |
1047 |
< |
* first argument <tt>!=</tt> the second |
1047 |
> |
* first argument {@code !=} the second. |
1048 |
|
*/ |
1049 |
|
public static BinaryPredicate<Object, Object> nonidentityPredicate() { |
1050 |
|
return NonidentityPredicate.predicate; |
1059 |
|
|
1060 |
|
/** |
1061 |
|
* Returns a predicate evaluating to true if the |
1062 |
< |
* first argument <tt>!=</tt> the second |
1062 |
> |
* first argument {@code !=} the second. |
1063 |
|
*/ |
1064 |
|
public static BinaryIntPredicate intInequalityPredicate() { |
1065 |
|
return IntInequalityPredicate.predicate; |
1074 |
|
|
1075 |
|
/** |
1076 |
|
* Returns a predicate evaluating to true if the |
1077 |
< |
* first argument <tt>==</tt> the second |
1077 |
> |
* first argument {@code ==} the second. |
1078 |
|
*/ |
1079 |
|
public static BinaryLongPredicate longInequalityPredicate() { |
1080 |
|
return LongInequalityPredicate.predicate; |
1089 |
|
|
1090 |
|
/** |
1091 |
|
* Returns a predicate evaluating to true if the |
1092 |
< |
* first argument <tt>!=</tt> the second |
1092 |
> |
* first argument {@code !=} the second. |
1093 |
|
*/ |
1094 |
|
public static BinaryDoublePredicate doubleInequalityPredicate() { |
1095 |
|
return DoubleInequalityPredicate.predicate; |