|
19 | 19 |
|
20 | 20 | import java.util.ArrayList;
|
21 | 21 | import java.util.Arrays;
|
| 22 | +import java.util.Collection; |
22 | 23 | import java.util.Comparator;
|
23 | 24 | import java.util.List;
|
| 25 | +import java.util.Map; |
24 | 26 | import java.util.concurrent.ConcurrentHashMap;
|
25 | 27 | import java.util.concurrent.Future;
|
26 | 28 | import java.util.concurrent.TimeUnit;
|
|
86 | 88 | import rx.operators.OperationTimeInterval;
|
87 | 89 | import rx.operators.OperationTimeout;
|
88 | 90 | import rx.operators.OperationTimestamp;
|
| 91 | +import rx.operators.OperationToMap; |
| 92 | +import rx.operators.OperationToMultimap; |
89 | 93 | import rx.operators.OperationToObservableFuture;
|
90 | 94 | import rx.operators.OperationToObservableIterable;
|
91 | 95 | import rx.operators.OperationToObservableList;
|
@@ -5861,4 +5865,127 @@ public static <R> Observable<R> when(Plan0<R> p1, Plan0<R> p2, Plan0<R> p3, Plan
|
5861 | 5865 | public static <R> Observable<R> when(Plan0<R> p1, Plan0<R> p2, Plan0<R> p3, Plan0<R> p4, Plan0<R> p5, Plan0<R> p6, Plan0<R> p7, Plan0<R> p8, Plan0<R> p9) {
|
5862 | 5866 | return create(OperationJoinPatterns.when(p1, p2, p3, p4, p5, p6, p7, p8, p9));
|
5863 | 5867 | }
|
| 5868 | + |
| 5869 | + /** |
| 5870 | + * Return an Observable that emits a single HashMap containing all items |
| 5871 | + * emitted by the source Observable, mapped by the keys returned by the |
| 5872 | + * {@code keySelector} function. |
| 5873 | + * |
| 5874 | + * If a source item maps to the same key, the HashMap will contain the latest |
| 5875 | + * of those items. |
| 5876 | + * |
| 5877 | + * @param keySelector the function that extracts the key from the source items |
| 5878 | + * to be used as keys in the HashMap. |
| 5879 | + * @return an Observable that emits a single HashMap containing the mapped |
| 5880 | + * values of the source Observable |
| 5881 | + * @see <a href='http://msdn.microsoft.com/en-us/library/hh229137(v=vs.103).aspx'>MSDN: Observable.ToDictionary</a> |
| 5882 | + */ |
| 5883 | + public <K> Observable<Map<K, T>> toMap(Func1<? super T, ? extends K> keySelector) { |
| 5884 | + return create(OperationToMap.toMap(this, keySelector)); |
| 5885 | + } |
| 5886 | + |
| 5887 | + /** |
| 5888 | + * Return an Observable that emits a single HashMap containing elements with |
| 5889 | + * key and value extracted from the values emitted by the source Observable. |
| 5890 | + * |
| 5891 | + * If a source item maps to the same key, the HashMap will contain the latest |
| 5892 | + * of those items. |
| 5893 | + * |
| 5894 | + * @param keySelector the function that extracts the key from the source items |
| 5895 | + * to be used as key in the HashMap |
| 5896 | + * @param valueSelector the function that extracts the value from the source items |
| 5897 | + * to be used as value in the HashMap |
| 5898 | + * @return an Observable that emits a single HashMap containing the mapped |
| 5899 | + * values of the source Observable |
| 5900 | + * @see <a href='http://msdn.microsoft.com/en-us/library/hh212075(v=vs.103).aspx'>MSDN: Observable.ToDictionary</a> |
| 5901 | + */ |
| 5902 | + public <K, V> Observable<Map<K, V>> toMap(Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector) { |
| 5903 | + return create(OperationToMap.toMap(this, keySelector, valueSelector)); |
| 5904 | + } |
| 5905 | + |
| 5906 | + /** |
| 5907 | + * Return an Observable that emits a single Map, returned by the mapFactory function, |
| 5908 | + * containing key and value extracted from the values emitted by the source Observable. |
| 5909 | + * |
| 5910 | + * @param keySelector the function that extracts the key from the source items |
| 5911 | + * to be used as key in the Map |
| 5912 | + * @param valueSelector the function that extracts the value from the source items |
| 5913 | + * to be used as value in the Map |
| 5914 | + * @param mapFactory the function that returns an Map instance to be used |
| 5915 | + * @return an Observable that emits a single Map containing the mapped |
| 5916 | + * values of the source Observable |
| 5917 | + */ |
| 5918 | + public <K, V> Observable<Map<K, V>> toMap(Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func0<? extends Map<K, V>> mapFactory) { |
| 5919 | + return create(OperationToMap.toMap(this, keySelector, valueSelector, mapFactory)); |
| 5920 | + } |
| 5921 | + |
| 5922 | + /** |
| 5923 | + * Return an Observable that emits a single HashMap containing an ArrayList of elements, |
| 5924 | + * emitted by the source Observable and keyed by the keySelector function. |
| 5925 | + * |
| 5926 | + * @param keySelector the function that extracts the key from the source items |
| 5927 | + * to be used as key in the HashMap |
| 5928 | + * @return an Observable that emits a single HashMap containing an ArrayList of elements |
| 5929 | + * mapped from the source Observable |
| 5930 | + * @see <a href='http://msdn.microsoft.com/en-us/library/hh212098(v=vs.103).aspx'>MSDN: Observable.ToLookup</a> |
| 5931 | + */ |
| 5932 | + public <K> Observable<Map<K, Collection<T>>> toMultimap(Func1<? super T, ? extends K> keySelector) { |
| 5933 | + return create(OperationToMultimap.toMultimap(this, keySelector)); |
| 5934 | + } |
| 5935 | + |
| 5936 | + /** |
| 5937 | + * Return an Observable that emits a single HashMap containing an ArrayList of values, |
| 5938 | + * extracted by the valueSelector function, emitted by the source Observable |
| 5939 | + * and keyed by the keySelector function. |
| 5940 | + * |
| 5941 | + * @param keySelector the function that extracts the key from the source items |
| 5942 | + * to be used as key in the HashMap |
| 5943 | + * @param valueSelector the function that extracts the value from the source items |
| 5944 | + * to be used as value in the Map |
| 5945 | + * @return an Observable that emits a single HashMap containing an ArrayList of elements |
| 5946 | + * mapped from the source Observable |
| 5947 | + * |
| 5948 | + * @see <a href='http://msdn.microsoft.com/en-us/library/hh229101(v=vs.103).aspx'>MSDN: Observable.ToLookup</a> |
| 5949 | + */ |
| 5950 | + public <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector) { |
| 5951 | + return create(OperationToMultimap.toMultimap(this, keySelector, valueSelector)); |
| 5952 | + } |
| 5953 | + |
| 5954 | + /** |
| 5955 | + * Return an Observable that emits a single Map, returned by the mapFactory function, |
| 5956 | + * containing an ArrayList of values, extracted by the valueSelector function, |
| 5957 | + * emitted by the source Observable and keyed by the |
| 5958 | + * keySelector function. |
| 5959 | + * |
| 5960 | + * @param keySelector the function that extracts the key from the source items |
| 5961 | + * to be used as key in the Map |
| 5962 | + * @param valueSelector the function that extracts the value from the source items |
| 5963 | + * to be used as value in the Map |
| 5964 | + * @param mapFactory the function that returns an Map instance to be used |
| 5965 | + * @return an Observable that emits a single Map containing the list of mapped values |
| 5966 | + * of the source observable. |
| 5967 | + */ |
| 5968 | + public <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func0<? extends Map<K, Collection<V>>> mapFactory) { |
| 5969 | + return create(OperationToMultimap.toMultimap(this, keySelector, valueSelector, mapFactory)); |
| 5970 | + } |
| 5971 | + |
| 5972 | + /** |
| 5973 | + * Return an Observable that emits a single Map, returned by the mapFactory function, |
| 5974 | + * containing a custom collection of values, extracted by the valueSelector function, |
| 5975 | + * emitted by the source Observable and keyed by the |
| 5976 | + * keySelector function. |
| 5977 | + * |
| 5978 | + * @param keySelector the function that extracts the key from the source items |
| 5979 | + * to be used as key in the Map |
| 5980 | + * @param valueSelector the function that extracts the value from the source items |
| 5981 | + * to be used as value in the Map |
| 5982 | + * @param mapFactory the function that returns an Map instance to be used |
| 5983 | + * @param collectionFactory the function that returns a Collection instance for |
| 5984 | + * a particular key to be used in the Map |
| 5985 | + * @return an Observable that emits a single Map containing the collection of mapped values |
| 5986 | + * of the source observable. |
| 5987 | + */ |
| 5988 | + public <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func0<? extends Map<K, Collection<V>>> mapFactory, Func1<? super K, ? extends Collection<V>> collectionFactory) { |
| 5989 | + return create(OperationToMultimap.toMultimap(this, keySelector, valueSelector, mapFactory, collectionFactory)); |
| 5990 | + } |
5864 | 5991 | }
|
0 commit comments