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 ;
87
89
import rx .operators .OperationTimeInterval ;
88
90
import rx .operators .OperationTimeout ;
89
91
import rx .operators .OperationTimestamp ;
92
+ import rx .operators .OperationToMap ;
93
+ import rx .operators .OperationToMultimap ;
90
94
import rx .operators .OperationToObservableFuture ;
91
95
import rx .operators .OperationToObservableIterable ;
92
96
import rx .operators .OperationToObservableList ;
@@ -5943,6 +5947,7 @@ public static <R> Observable<R> when(Plan0<R> p1, Plan0<R> p2, Plan0<R> p3, Plan
5943
5947
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 ) {
5944
5948
return create (OperationJoinPatterns .when (p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 , p9 ));
5945
5949
}
5950
+
5946
5951
/**
5947
5952
* Correlates the elements of two sequences based on overlapping durations.
5948
5953
* @param right The right observable sequence to join elements for.
@@ -5964,5 +5969,128 @@ public <TRight, TLeftDuration, TRightDuration, R> Observable<R> join(Observable<
5964
5969
Func2 <T , TRight , R > resultSelector ) {
5965
5970
return create (new OperationJoin <T , TRight , TLeftDuration , TRightDuration , R >(this , right , leftDurationSelector , rightDurationSelector , resultSelector ));
5966
5971
}
5972
+
5973
+ /**
5974
+ * Return an Observable that emits a single HashMap containing all items
5975
+ * emitted by the source Observable, mapped by the keys returned by the
5976
+ * {@code keySelector} function.
5977
+ *
5978
+ * If a source item maps to the same key, the HashMap will contain the latest
5979
+ * of those items.
5980
+ *
5981
+ * @param keySelector the function that extracts the key from the source items
5982
+ * to be used as keys in the HashMap.
5983
+ * @return an Observable that emits a single HashMap containing the mapped
5984
+ * values of the source Observable
5985
+ * @see <a href='http://msdn.microsoft.com/en-us/library/hh229137(v=vs.103).aspx'>MSDN: Observable.ToDictionary</a>
5986
+ */
5987
+ public <K > Observable <Map <K , T >> toMap (Func1 <? super T , ? extends K > keySelector ) {
5988
+ return create (OperationToMap .toMap (this , keySelector ));
5989
+ }
5990
+
5991
+ /**
5992
+ * Return an Observable that emits a single HashMap containing elements with
5993
+ * key and value extracted from the values emitted by the source Observable.
5994
+ *
5995
+ * If a source item maps to the same key, the HashMap will contain the latest
5996
+ * of those items.
5997
+ *
5998
+ * @param keySelector the function that extracts the key from the source items
5999
+ * to be used as key in the HashMap
6000
+ * @param valueSelector the function that extracts the value from the source items
6001
+ * to be used as value in the HashMap
6002
+ * @return an Observable that emits a single HashMap containing the mapped
6003
+ * values of the source Observable
6004
+ * @see <a href='http://msdn.microsoft.com/en-us/library/hh212075(v=vs.103).aspx'>MSDN: Observable.ToDictionary</a>
6005
+ */
6006
+ public <K , V > Observable <Map <K , V >> toMap (Func1 <? super T , ? extends K > keySelector , Func1 <? super T , ? extends V > valueSelector ) {
6007
+ return create (OperationToMap .toMap (this , keySelector , valueSelector ));
6008
+ }
6009
+
6010
+ /**
6011
+ * Return an Observable that emits a single Map, returned by the mapFactory function,
6012
+ * containing key and value extracted from the values emitted by the source Observable.
6013
+ *
6014
+ * @param keySelector the function that extracts the key from the source items
6015
+ * to be used as key in the Map
6016
+ * @param valueSelector the function that extracts the value from the source items
6017
+ * to be used as value in the Map
6018
+ * @param mapFactory the function that returns an Map instance to be used
6019
+ * @return an Observable that emits a single Map containing the mapped
6020
+ * values of the source Observable
6021
+ */
6022
+ 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 ) {
6023
+ return create (OperationToMap .toMap (this , keySelector , valueSelector , mapFactory ));
6024
+ }
6025
+
6026
+ /**
6027
+ * Return an Observable that emits a single HashMap containing an ArrayList of elements,
6028
+ * emitted by the source Observable and keyed by the keySelector function.
6029
+ *
6030
+ * @param keySelector the function that extracts the key from the source items
6031
+ * to be used as key in the HashMap
6032
+ * @return an Observable that emits a single HashMap containing an ArrayList of elements
6033
+ * mapped from the source Observable
6034
+ * @see <a href='http://msdn.microsoft.com/en-us/library/hh212098(v=vs.103).aspx'>MSDN: Observable.ToLookup</a>
6035
+ */
6036
+ public <K > Observable <Map <K , Collection <T >>> toMultimap (Func1 <? super T , ? extends K > keySelector ) {
6037
+ return create (OperationToMultimap .toMultimap (this , keySelector ));
6038
+ }
6039
+
6040
+ /**
6041
+ * Return an Observable that emits a single HashMap containing an ArrayList of values,
6042
+ * extracted by the valueSelector function, emitted by the source Observable
6043
+ * and keyed by the keySelector function.
6044
+ *
6045
+ * @param keySelector the function that extracts the key from the source items
6046
+ * to be used as key in the HashMap
6047
+ * @param valueSelector the function that extracts the value from the source items
6048
+ * to be used as value in the Map
6049
+ * @return an Observable that emits a single HashMap containing an ArrayList of elements
6050
+ * mapped from the source Observable
6051
+ *
6052
+ * @see <a href='http://msdn.microsoft.com/en-us/library/hh229101(v=vs.103).aspx'>MSDN: Observable.ToLookup</a>
6053
+ */
6054
+ public <K , V > Observable <Map <K , Collection <V >>> toMultimap (Func1 <? super T , ? extends K > keySelector , Func1 <? super T , ? extends V > valueSelector ) {
6055
+ return create (OperationToMultimap .toMultimap (this , keySelector , valueSelector ));
6056
+ }
6057
+
6058
+ /**
6059
+ * Return an Observable that emits a single Map, returned by the mapFactory function,
6060
+ * containing an ArrayList of values, extracted by the valueSelector function,
6061
+ * emitted by the source Observable and keyed by the
6062
+ * keySelector function.
6063
+ *
6064
+ * @param keySelector the function that extracts the key from the source items
6065
+ * to be used as key in the Map
6066
+ * @param valueSelector the function that extracts the value from the source items
6067
+ * to be used as value in the Map
6068
+ * @param mapFactory the function that returns an Map instance to be used
6069
+ * @return an Observable that emits a single Map containing the list of mapped values
6070
+ * of the source observable.
6071
+ */
6072
+ 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 ) {
6073
+ return create (OperationToMultimap .toMultimap (this , keySelector , valueSelector , mapFactory ));
6074
+ }
6075
+
6076
+ /**
6077
+ * Return an Observable that emits a single Map, returned by the mapFactory function,
6078
+ * containing a custom collection of values, extracted by the valueSelector function,
6079
+ * emitted by the source Observable and keyed by the
6080
+ * keySelector function.
6081
+ *
6082
+ * @param keySelector the function that extracts the key from the source items
6083
+ * to be used as key in the Map
6084
+ * @param valueSelector the function that extracts the value from the source items
6085
+ * to be used as value in the Map
6086
+ * @param mapFactory the function that returns an Map instance to be used
6087
+ * @param collectionFactory the function that returns a Collection instance for
6088
+ * a particular key to be used in the Map
6089
+ * @return an Observable that emits a single Map containing the collection of mapped values
6090
+ * of the source observable.
6091
+ */
6092
+ 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 ) {
6093
+ return create (OperationToMultimap .toMultimap (this , keySelector , valueSelector , mapFactory , collectionFactory ));
6094
+ }
5967
6095
}
5968
6096
0 commit comments