|
19 | 19 |
|
20 | 20 | import java.util.ArrayList;
|
21 | 21 | import java.util.Arrays;
|
| 22 | +import java.util.Comparator; |
22 | 23 | import java.util.List;
|
23 | 24 | import java.util.concurrent.ConcurrentHashMap;
|
24 | 25 | import java.util.concurrent.Future;
|
|
54 | 55 | import rx.operators.OperationMaterialize;
|
55 | 56 | import rx.operators.OperationMerge;
|
56 | 57 | import rx.operators.OperationMergeDelayError;
|
| 58 | +import rx.operators.OperationMinMax; |
57 | 59 | import rx.operators.OperationMulticast;
|
58 | 60 | import rx.operators.OperationObserveOn;
|
59 | 61 | import rx.operators.OperationOnErrorResumeNextViaFunction;
|
@@ -3631,6 +3633,126 @@ public static Observable<Double> averageDoubles(Observable<Double> source) {
|
3631 | 3633 | return OperationAverage.averageDoubles(source);
|
3632 | 3634 | }
|
3633 | 3635 |
|
| 3636 | + /** |
| 3637 | + * Returns the minimum element in an observable sequence. |
| 3638 | + * If there are more than one minimum elements, returns the last one. |
| 3639 | + * For an empty source, it causes an {@link IllegalArgumentException}. |
| 3640 | + * |
| 3641 | + * @param source |
| 3642 | + * an observable sequence to determine the minimum element of. |
| 3643 | + * @return an observable emitting the minimum element. |
| 3644 | + * @throws IllegalArgumentException |
| 3645 | + * if the source is empty |
| 3646 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh229715(v=vs.103).aspx">MSDN: Observable.Min</a> |
| 3647 | + */ |
| 3648 | + public static <T extends Comparable<T>> Observable<T> min(Observable<T> source) { |
| 3649 | + return OperationMinMax.min(source); |
| 3650 | + } |
| 3651 | + |
| 3652 | + /** |
| 3653 | + * Returns the minimum element in an observable sequence according to the specified comparator. |
| 3654 | + * If there are more than one minimum elements, returns the last one. |
| 3655 | + * For an empty source, it causes an {@link IllegalArgumentException}. |
| 3656 | + * |
| 3657 | + * @param comparator |
| 3658 | + * the comparer used to compare elements. |
| 3659 | + * @return an observable emitting the minimum value according to the specified comparator. |
| 3660 | + * @throws IllegalArgumentException |
| 3661 | + * if the source is empty |
| 3662 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh229095(v=vs.103).aspx">MSDN: Observable.Min</a> |
| 3663 | + */ |
| 3664 | + public Observable<T> min(Comparator<T> comparator) { |
| 3665 | + return OperationMinMax.min(this, comparator); |
| 3666 | + } |
| 3667 | + |
| 3668 | + /** |
| 3669 | + * Returns the elements in an observable sequence with the minimum key value. |
| 3670 | + * For an empty source, it returns an observable emitting an empty List. |
| 3671 | + * |
| 3672 | + * @param selector |
| 3673 | + * the key selector function. |
| 3674 | + * @return an observable emitting a List of the elements with the minimum key value. |
| 3675 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh228970(v=vs.103).aspx">MSDN: Observable.MinBy</a> |
| 3676 | + */ |
| 3677 | + public <R extends Comparable<R>> Observable<List<T>> minBy(Func1<T, R> selector) { |
| 3678 | + return OperationMinMax.minBy(this, selector); |
| 3679 | + } |
| 3680 | + |
| 3681 | + /** |
| 3682 | + * Returns the elements in an observable sequence with the minimum key value according to the specified comparator. |
| 3683 | + * For an empty source, it returns an observable emitting an empty List. |
| 3684 | + * |
| 3685 | + * @param selector |
| 3686 | + * the key selector function. |
| 3687 | + * @param comparator |
| 3688 | + * the comparator used to compare key values. |
| 3689 | + * @return an observable emitting a List of the elements with the minimum key value according to the specified comparator. |
| 3690 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh228970(v=vs.103).aspx">MSDN: Observable.MinBy</a> |
| 3691 | + */ |
| 3692 | + public <R> Observable<List<T>> minBy(Func1<T, R> selector, Comparator<R> comparator) { |
| 3693 | + return OperationMinMax.minBy(this, selector, comparator); |
| 3694 | + } |
| 3695 | + |
| 3696 | + /** |
| 3697 | + * Returns the maximum element in an observable sequence. |
| 3698 | + * If there are more than one maximum elements, returns the last one. |
| 3699 | + * For an empty source, it causes an {@link IllegalArgumentException}. |
| 3700 | + * |
| 3701 | + * @param source |
| 3702 | + * an observable sequence to determine the maximum element of. |
| 3703 | + * @return an observable emitting the maximum element. |
| 3704 | + * @throws IllegalArgumentException |
| 3705 | + * if the source is empty. |
| 3706 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh211837(v=vs.103).aspx">MSDN: Observable.Max</a> |
| 3707 | + */ |
| 3708 | + public static <T extends Comparable<T>> Observable<T> max(Observable<T> source) { |
| 3709 | + return OperationMinMax.max(source); |
| 3710 | + } |
| 3711 | + |
| 3712 | + /** |
| 3713 | + * Returns the maximum element in an observable sequence according to the specified comparator. |
| 3714 | + * If there are more than one maximum elements, returns the last one. |
| 3715 | + * For an empty source, it causes an {@link IllegalArgumentException}. |
| 3716 | + * |
| 3717 | + * @param comparator |
| 3718 | + * the comparer used to compare elements. |
| 3719 | + * @return an observable emitting the maximum value according to the specified comparator. |
| 3720 | + * @throws IllegalArgumentException |
| 3721 | + * if the source is empty. |
| 3722 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh211635(v=vs.103).aspx">MSDN: Observable.Max</a> |
| 3723 | + */ |
| 3724 | + public Observable<T> max(Comparator<T> comparator) { |
| 3725 | + return OperationMinMax.max(this, comparator); |
| 3726 | + } |
| 3727 | + |
| 3728 | + /** |
| 3729 | + * Returns the elements in an observable sequence with the maximum key value. |
| 3730 | + * For an empty source, it returns an observable emitting an empty List. |
| 3731 | + * |
| 3732 | + * @param selector |
| 3733 | + * the key selector function. |
| 3734 | + * @return an observable emitting a List of the elements with the maximum key value. |
| 3735 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh229058(v=vs.103).aspx">MSDN: Observable.MaxBy</a> |
| 3736 | + */ |
| 3737 | + public <R extends Comparable<R>> Observable<List<T>> maxBy(Func1<T, R> selector) { |
| 3738 | + return OperationMinMax.maxBy(this, selector); |
| 3739 | + } |
| 3740 | + |
| 3741 | + /** |
| 3742 | + * Returns the elements in an observable sequence with the maximum key value according to the specified comparator. |
| 3743 | + * For an empty source, it returns an observable emitting an empty List. |
| 3744 | + * |
| 3745 | + * @param selector |
| 3746 | + * the key selector function. |
| 3747 | + * @param comparator |
| 3748 | + * the comparator used to compare key values. |
| 3749 | + * @return an observable emitting a List of the elements with the maximum key value according to the specified comparator. |
| 3750 | + * @see <a href="http://msdn.microsoft.com/en-us/library/hh244330(v=vs.103).aspx">MSDN: Observable.MaxBy</a> |
| 3751 | + */ |
| 3752 | + public <R> Observable<List<T>> maxBy(Func1<T, R> selector, Comparator<R> comparator) { |
| 3753 | + return OperationMinMax.maxBy(this, selector, comparator); |
| 3754 | + } |
| 3755 | + |
3634 | 3756 | /**
|
3635 | 3757 | * Returns a {@link ConnectableObservable} that shares a single subscription to the underlying
|
3636 | 3758 | * Observable that will replay all of its items and notifications to any future {@link Observer}.
|
|
0 commit comments