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

Comparing jsr166/src/extra166y/CommonOps.java (file contents):
Revision 1.5 by jsr166, Mon Dec 5 04:08:47 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 jsr166y.*;
10   import static extra166y.Ops.*;
11   import java.util.*;
# Line 17 | Line 18 | public class CommonOps {
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) {
# Line 100 | Line 101 | public class CommonOps {
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       */
# Line 118 | Line 119 | public class CommonOps {
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       */
# Line 136 | Line 137 | public class CommonOps {
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;
# Line 152 | Line 153 | public class CommonOps {
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;
# Line 167 | Line 168 | public class CommonOps {
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;
# Line 181 | Line 182 | public class CommonOps {
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) {
# Line 194 | Line 195 | public class CommonOps {
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) {
# Line 206 | Line 207 | public class CommonOps {
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;
# Line 222 | Line 223 | public class CommonOps {
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;
# Line 237 | Line 238 | public class CommonOps {
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;
# Line 251 | Line 252 | public class CommonOps {
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) {
# Line 264 | Line 265 | public class CommonOps {
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) {
# Line 277 | Line 278 | public class CommonOps {
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,
# Line 289 | Line 290 | public class CommonOps {
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,
# Line 301 | Line 302 | public class CommonOps {
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,
# Line 313 | Line 314 | public class CommonOps {
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,
# Line 325 | Line 326 | public class CommonOps {
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,
# Line 337 | Line 338 | public class CommonOps {
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,
# Line 349 | Line 350 | public class CommonOps {
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,
# Line 361 | Line 362 | public class CommonOps {
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,
# Line 373 | Line 374 | public class CommonOps {
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,
# Line 385 | Line 386 | public class CommonOps {
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,
# Line 397 | Line 398 | public class CommonOps {
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,
# Line 409 | Line 410 | public class CommonOps {
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,
# Line 421 | Line 422 | public class CommonOps {
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,
# Line 433 | Line 434 | public class CommonOps {
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,
# Line 445 | Line 446 | public class CommonOps {
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,
# Line 457 | Line 458 | public class CommonOps {
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,
# Line 469 | Line 470 | public class CommonOps {
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,
# Line 481 | Line 482 | public class CommonOps {
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,
# Line 493 | Line 494 | public class CommonOps {
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,
# Line 505 | Line 506 | public class CommonOps {
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,
# Line 517 | Line 518 | public class CommonOps {
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,
# Line 529 | Line 530 | public class CommonOps {
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,
# Line 541 | Line 542 | public class CommonOps {
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,
# Line 553 | Line 554 | public class CommonOps {
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,
# Line 565 | Line 566 | public class CommonOps {
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,
# Line 577 | Line 578 | public class CommonOps {
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,
# Line 589 | Line 590 | public class CommonOps {
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,
# Line 600 | Line 601 | public class CommonOps {
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) {
# Line 610 | Line 611 | public class CommonOps {
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) {
# Line 620 | Line 621 | public class CommonOps {
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) {
# Line 630 | Line 631 | public class CommonOps {
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,
# Line 643 | Line 644 | public class CommonOps {
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,
# Line 656 | Line 657 | public class CommonOps {
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,
# Line 669 | Line 670 | public class CommonOps {
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,
# Line 683 | Line 684 | public class CommonOps {
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,
# Line 696 | Line 697 | public class CommonOps {
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,
# Line 709 | Line 710 | public class CommonOps {
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() {
716          return IsNonNullPredicate.predicate;
# Line 723 | Line 724 | public class CommonOps {
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() {
730          return IsNullPredicate.predicate;
# Line 761 | Line 762 | public class CommonOps {
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 {
# Line 770 | Line 771 | public class CommonOps {
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 {
# Line 779 | Line 780 | public class CommonOps {
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 {
# Line 790 | Line 791 | public class CommonOps {
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;
# Line 822 | Line 823 | public class CommonOps {
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       */
# Line 842 | Line 843 | public class CommonOps {
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;
# Line 857 | Line 858 | public class CommonOps {
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) {
# Line 897 | Line 898 | public class CommonOps {
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;
# Line 912 | Line 913 | public class CommonOps {
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) {
# Line 930 | Line 931 | public class CommonOps {
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       */
# Line 952 | Line 953 | public class CommonOps {
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;
# Line 967 | Line 968 | public class CommonOps {
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;
# Line 982 | Line 983 | public class CommonOps {
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;
# Line 997 | Line 998 | public class CommonOps {
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;
# Line 1012 | Line 1013 | public class CommonOps {
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;
# Line 1028 | Line 1029 | public class CommonOps {
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;
# Line 1043 | Line 1044 | public class CommonOps {
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;
# Line 1058 | Line 1059 | public class CommonOps {
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;
# Line 1073 | Line 1074 | public class CommonOps {
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;
# Line 1088 | Line 1089 | public class CommonOps {
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines