Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.Aggregates.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 using System.Collections.Generic;
4 using System.Linq;
5
6 namespace System.Reactive.Linq
7 {
8 public static partial class Observable
9 {
10 #region + Aggregate +
11
12 /// <summary>
13 /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
14 /// For aggregation behavior with incremental intermediate results, see <see cref="Observable.Scan&lt;TSource, Accumulate&gt;"/>.
15 /// </summary>
16 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
17 /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
18 /// <param name="source">An observable sequence to aggregate over.</param>
19 /// <param name="seed">The initial accumulator value.</param>
20 /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
21 /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
22 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="accumulator"/> is null.</exception>
23 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
24 public static IObservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
25 {
26 if (source == null)
27 throw new ArgumentNullException("source");
28 if (accumulator == null)
29 throw new ArgumentNullException("accumulator");
30
31 return s_impl.Aggregate<TSource, TAccumulate>(source, seed, accumulator);
32 }
33
34 /// <summary>
35 /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value,
36 /// and the specified result selector function is used to select the result value.
37 /// </summary>
38 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
39 /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
40 /// <typeparam name="TResult">The type of the resulting value.</typeparam>
41 /// <param name="source">An observable sequence to aggregate over.</param>
42 /// <param name="seed">The initial accumulator value.</param>
43 /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
44 /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
45 /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
46 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="accumulator"/> or <paramref name="resultSelector"/> is null.</exception>
47 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
48 public static IObservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector)
49 {
50 if (source == null)
51 throw new ArgumentNullException("source");
52 if (accumulator == null)
53 throw new ArgumentNullException("accumulator");
54 if (resultSelector == null)
55 throw new ArgumentNullException("resultSelector");
56
57 return s_impl.Aggregate<TSource, TAccumulate, TResult>(source, seed, accumulator, resultSelector);
58 }
59
60 /// <summary>
61 /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
62 /// For aggregation behavior with incremental intermediate results, see <see cref="Observable.Scan&lt;TSource&gt;"/>.
63 /// </summary>
64 /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
65 /// <param name="source">An observable sequence to aggregate over.</param>
66 /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
67 /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
68 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="accumulator"/> is null.</exception>
69 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
70 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
71 public static IObservable<TSource> Aggregate<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
72 {
73 if (source == null)
74 throw new ArgumentNullException("source");
75 if (accumulator == null)
76 throw new ArgumentNullException("accumulator");
77
78 return s_impl.Aggregate<TSource>(source, accumulator);
79 }
80
81 #endregion
82
83 #region + All +
84
85 /// <summary>
86 /// Determines whether all elements of an observable sequence satisfy a condition.
87 /// </summary>
88 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
89 /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
90 /// <param name="predicate">A function to test each element for a condition.</param>
91 /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
92 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
93 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
94 public static IObservable<bool> All<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
95 {
96 if (source == null)
97 throw new ArgumentNullException("source");
98 if (predicate == null)
99 throw new ArgumentNullException("predicate");
100
101 return s_impl.All<TSource>(source, predicate);
102 }
103
104 #endregion
105
106 #region + Any +
107
108 /// <summary>
109 /// Determines whether an observable sequence contains any elements.
110 /// </summary>
111 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
112 /// <param name="source">An observable sequence to check for non-emptiness.</param>
113 /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
114 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
115 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
116 public static IObservable<bool> Any<TSource>(this IObservable<TSource> source)
117 {
118 if (source == null)
119 throw new ArgumentNullException("source");
120
121 return s_impl.Any<TSource>(source);
122 }
123
124 /// <summary>
125 /// Determines whether any element of an observable sequence satisfies a condition.
126 /// </summary>
127 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
128 /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
129 /// <param name="predicate">A function to test each element for a condition.</param>
130 /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
131 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
132 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
133 public static IObservable<bool> Any<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
134 {
135 if (source == null)
136 throw new ArgumentNullException("source");
137 if (predicate == null)
138 throw new ArgumentNullException("predicate");
139
140 return s_impl.Any<TSource>(source, predicate);
141 }
142
143 #endregion
144
145 #region + Average +
146
147 /// <summary>
148 /// Computes the average of an observable sequence of <see cref="T:System.Double" /> values.
149 /// </summary>
150 /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the average of.</param>
151 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
152 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
153 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
154 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
155 public static IObservable<double> Average(this IObservable<double> source)
156 {
157 if (source == null)
158 throw new ArgumentNullException("source");
159
160 return s_impl.Average(source);
161 }
162
163 /// <summary>
164 /// Computes the average of an observable sequence of <see cref="T:System.Single" /> values.
165 /// </summary>
166 /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the average of.</param>
167 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
168 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
169 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
170 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
171 public static IObservable<float> Average(this IObservable<float> source)
172 {
173 if (source == null)
174 throw new ArgumentNullException("source");
175
176 return s_impl.Average(source);
177 }
178
179 /// <summary>
180 /// Computes the average of an observable sequence of <see cref="T:System.Decimal" /> values.
181 /// </summary>
182 /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the average of.</param>
183 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
184 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
185 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
186 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
187 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
188 public static IObservable<decimal> Average(this IObservable<decimal> source)
189 {
190 if (source == null)
191 throw new ArgumentNullException("source");
192
193 return s_impl.Average(source);
194 }
195
196 /// <summary>
197 /// Computes the average of an observable sequence of <see cref="T:System.Int32" /> values.
198 /// </summary>
199 /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the average of.</param>
200 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
201 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
202 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
203 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
204 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
205 public static IObservable<double> Average(this IObservable<int> source)
206 {
207 if (source == null)
208 throw new ArgumentNullException("source");
209
210 return s_impl.Average(source);
211 }
212
213 /// <summary>
214 /// Computes the average of an observable sequence of <see cref="T:System.Int64" /> values.
215 /// </summary>
216 /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the average of.</param>
217 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
218 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
219 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
220 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
221 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
222 public static IObservable<double> Average(this IObservable<long> source)
223 {
224 if (source == null)
225 throw new ArgumentNullException("source");
226
227 return s_impl.Average(source);
228 }
229
230 /// <summary>
231 /// Computes the average of an observable sequence of nullable <see cref="T:System.Double" /> values.
232 /// </summary>
233 /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the average of.</param>
234 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
235 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
236 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
237 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
238 public static IObservable<double?> Average(this IObservable<double?> source)
239 {
240 if (source == null)
241 throw new ArgumentNullException("source");
242
243 return s_impl.Average(source);
244 }
245
246 /// <summary>
247 /// Computes the average of an observable sequence of nullable <see cref="T:System.Single" /> values.
248 /// </summary>
249 /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the average of.</param>
250 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
251 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
252 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
253 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
254 public static IObservable<float?> Average(this IObservable<float?> source)
255 {
256 if (source == null)
257 throw new ArgumentNullException("source");
258
259 return s_impl.Average(source);
260 }
261
262 /// <summary>
263 /// Computes the average of an observable sequence of nullable <see cref="T:System.Decimal" /> values.
264 /// </summary>
265 /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the average of.</param>
266 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
267 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
268 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
269 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
270 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
271 public static IObservable<decimal?> Average(this IObservable<decimal?> source)
272 {
273 if (source == null)
274 throw new ArgumentNullException("source");
275
276 return s_impl.Average(source);
277 }
278
279 /// <summary>
280 /// Computes the average of an observable sequence of nullable <see cref="T:System.Int32" /> values.
281 /// </summary>
282 /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the average of.</param>
283 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
284 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
285 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
286 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
287 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
288 public static IObservable<double?> Average(this IObservable<int?> source)
289 {
290 if (source == null)
291 throw new ArgumentNullException("source");
292
293 return s_impl.Average(source);
294 }
295
296 /// <summary>
297 /// Computes the average of an observable sequence of nullable <see cref="T:System.Int64" /> values.
298 /// </summary>
299 /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the average of.</param>
300 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
301 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
302 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
303 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
304 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
305 public static IObservable<double?> Average(this IObservable<long?> source)
306 {
307 if (source == null)
308 throw new ArgumentNullException("source");
309
310 return s_impl.Average(source);
311 }
312
313 /// <summary>
314 /// Computes the average of an observable sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
315 /// </summary>
316 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
317 /// <param name="source">A sequence of values to calculate the average of.</param>
318 /// <param name="selector">A transform function to apply to each element.</param>
319 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
320 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
321 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
322 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
323 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
324 public static IObservable<decimal> Average<TSource>(this IObservable<TSource> source, Func<TSource, decimal> selector)
325 {
326 if (source == null)
327 throw new ArgumentNullException("source");
328 if (selector == null)
329 throw new ArgumentNullException("selector");
330
331 return s_impl.Average<TSource>(source, selector);
332 }
333
334 /// <summary>
335 /// Computes the average of an observable sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
336 /// </summary>
337 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
338 /// <param name="source">A sequence of values to calculate the average of.</param>
339 /// <param name="selector">A transform function to apply to each element.</param>
340 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
341 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
342 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
343 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
344 public static IObservable<double> Average<TSource>(this IObservable<TSource> source, Func<TSource, double> selector)
345 {
346 if (source == null)
347 throw new ArgumentNullException("source");
348 if (selector == null)
349 throw new ArgumentNullException("selector");
350
351 return s_impl.Average<TSource>(source, selector);
352 }
353
354 /// <summary>
355 /// Computes the average of an observable sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
356 /// </summary>
357 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
358 /// <param name="source">A sequence of values to calculate the average of.</param>
359 /// <param name="selector">A transform function to apply to each element.</param>
360 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
361 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
362 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
363 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
364 public static IObservable<float> Average<TSource>(this IObservable<TSource> source, Func<TSource, float> selector)
365 {
366 if (source == null)
367 throw new ArgumentNullException("source");
368 if (selector == null)
369 throw new ArgumentNullException("selector");
370
371 return s_impl.Average<TSource>(source, selector);
372 }
373
374 /// <summary>
375 /// Computes the average of an observable sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
376 /// </summary>
377 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
378 /// <param name="source">A sequence of values to calculate the average of.</param>
379 /// <param name="selector">A transform function to apply to each element.</param>
380 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
381 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
382 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
383 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
384 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
385 public static IObservable<double> Average<TSource>(this IObservable<TSource> source, Func<TSource, int> selector)
386 {
387 if (source == null)
388 throw new ArgumentNullException("source");
389 if (selector == null)
390 throw new ArgumentNullException("selector");
391
392 return s_impl.Average<TSource>(source, selector);
393 }
394
395 /// <summary>
396 /// Computes the average of an observable sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
397 /// </summary>
398 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
399 /// <param name="source">A sequence of values to calculate the average of.</param>
400 /// <param name="selector">A transform function to apply to each element.</param>
401 /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
402 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
403 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
404 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
405 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
406 public static IObservable<double> Average<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)
407 {
408 if (source == null)
409 throw new ArgumentNullException("source");
410 if (selector == null)
411 throw new ArgumentNullException("selector");
412
413 return s_impl.Average<TSource>(source, selector);
414 }
415
416 /// <summary>
417 /// Computes the average of an observable sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
418 /// </summary>
419 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
420 /// <param name="source">A sequence of values to calculate the average of.</param>
421 /// <param name="selector">A transform function to apply to each element.</param>
422 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
423 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
424 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
425 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
426 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
427 public static IObservable<decimal?> Average<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)
428 {
429 if (source == null)
430 throw new ArgumentNullException("source");
431 if (selector == null)
432 throw new ArgumentNullException("selector");
433
434 return s_impl.Average<TSource>(source, selector);
435 }
436
437 /// <summary>
438 /// Computes the average of an observable sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
439 /// </summary>
440 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
441 /// <param name="source">A sequence of values to calculate the average of.</param>
442 /// <param name="selector">A transform function to apply to each element.</param>
443 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
444 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
445 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
446 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
447 public static IObservable<double?> Average<TSource>(this IObservable<TSource> source, Func<TSource, double?> selector)
448 {
449 if (source == null)
450 throw new ArgumentNullException("source");
451 if (selector == null)
452 throw new ArgumentNullException("selector");
453
454 return s_impl.Average<TSource>(source, selector);
455 }
456
457 /// <summary>
458 /// Computes the average of an observable sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
459 /// </summary>
460 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
461 /// <param name="source">A sequence of values to calculate the average of.</param>
462 /// <param name="selector">A transform function to apply to each element.</param>
463 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
464 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
465 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
466 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
467 public static IObservable<float?> Average<TSource>(this IObservable<TSource> source, Func<TSource, float?> selector)
468 {
469 if (source == null)
470 throw new ArgumentNullException("source");
471 if (selector == null)
472 throw new ArgumentNullException("selector");
473
474 return s_impl.Average<TSource>(source, selector);
475 }
476
477 /// <summary>
478 /// Computes the average of an observable sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
479 /// </summary>
480 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
481 /// <param name="source">A sequence of values to calculate the average of.</param>
482 /// <param name="selector">A transform function to apply to each element.</param>
483 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
484 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
485 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
486 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
487 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
488 public static IObservable<double?> Average<TSource>(this IObservable<TSource> source, Func<TSource, int?> selector)
489 {
490 if (source == null)
491 throw new ArgumentNullException("source");
492 if (selector == null)
493 throw new ArgumentNullException("selector");
494
495 return s_impl.Average<TSource>(source, selector);
496 }
497
498 /// <summary>
499 /// Computes the average of an observable sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
500 /// </summary>
501 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
502 /// <param name="source">A sequence of values to calculate the average of.</param>
503 /// <param name="selector">A transform function to apply to each element.</param>
504 /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
505 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
506 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
507 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
508 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
509 public static IObservable<double?> Average<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)
510 {
511 if (source == null)
512 throw new ArgumentNullException("source");
513 if (selector == null)
514 throw new ArgumentNullException("selector");
515
516 return s_impl.Average<TSource>(source, selector);
517 }
518
519 #endregion
520
521 #region + Contains +
522
523 /// <summary>
524 /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
525 /// </summary>
526 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
527 /// <param name="source">An observable sequence in which to locate a value.</param>
528 /// <param name="value">The value to locate in the source sequence.</param>
529 /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
530 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
531 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
532 public static IObservable<bool> Contains<TSource>(this IObservable<TSource> source, TSource value)
533 {
534 if (source == null)
535 throw new ArgumentNullException("source");
536
537 return s_impl.Contains<TSource>(source, value);
538 }
539
540 /// <summary>
541 /// Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer&lt;T&gt;.
542 /// </summary>
543 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
544 /// <param name="source">An observable sequence in which to locate a value.</param>
545 /// <param name="value">The value to locate in the source sequence.</param>
546 /// <param name="comparer">An equality comparer to compare elements.</param>
547 /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
548 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="comparer"/> is null.</exception>
549 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
550 public static IObservable<bool> Contains<TSource>(this IObservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
551 {
552 if (source == null)
553 throw new ArgumentNullException("source");
554 if (comparer == null)
555 throw new ArgumentNullException("comparer");
556
557 return s_impl.Contains<TSource>(source, value, comparer);
558 }
559
560 #endregion
561
562 #region + Count +
563
564 /// <summary>
565 /// Returns an observable sequence containing an <see cref="T:System.Int32" /> that represents the total number of elements in an observable sequence.
566 /// </summary>
567 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
568 /// <param name="source">An observable sequence that contains elements to be counted.</param>
569 /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
570 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
571 /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
572 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
573 public static IObservable<int> Count<TSource>(this IObservable<TSource> source)
574 {
575 if (source == null)
576 throw new ArgumentNullException("source");
577
578 return s_impl.Count<TSource>(source);
579 }
580
581 /// <summary>
582 /// Returns an observable sequence containing an <see cref="T:System.Int32" /> that represents how many elements in the specified observable sequence satisfy a condition.
583 /// </summary>
584 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
585 /// <param name="source">An observable sequence that contains elements to be counted.</param>
586 /// <param name="predicate">A function to test each element for a condition.</param>
587 /// <returns>An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function.</returns>
588 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
589 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
590 public static IObservable<int> Count<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
591 {
592 if (source == null)
593 throw new ArgumentNullException("source");
594 if (predicate == null)
595 throw new ArgumentNullException("predicate");
596
597 return s_impl.Count<TSource>(source, predicate);
598 }
599
600 #endregion
601
602 #region + ElementAt +
603
604 /// <summary>
605 /// Returns the element at a specified index in a sequence.
606 /// </summary>
607 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
608 /// <param name="source">Observable sequence to return the element from.</param>
609 /// <param name="index">The zero-based index of the element to retrieve.</param>
610 /// <returns>An observable sequence that produces the element at the specified position in the source sequence.</returns>
611 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
612 /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than zero.</exception>
613 /// <exception cref="ArgumentOutOfRangeException">(Asynchronous) <paramref name="index"/> is greater than or equal to the number of elements in the source sequence.</exception>
614 public static IObservable<TSource> ElementAt<TSource>(this IObservable<TSource> source, int index)
615 {
616 if (source == null)
617 throw new ArgumentNullException("source");
618 if (index < 0)
619 throw new ArgumentOutOfRangeException("index");
620
621 return s_impl.ElementAt<TSource>(source, index);
622 }
623
624 #endregion
625
626 #region + ElementAtOrDefault +
627
628 /// <summary>
629 /// Returns the element at a specified index in a sequence or a default value if the index is out of range.
630 /// </summary>
631 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
632 /// <param name="source">Observable sequence to return the element from.</param>
633 /// <param name="index">The zero-based index of the element to retrieve.</param>
634 /// <returns>An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.</returns>
635 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
636 /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than zero.</exception>
637 public static IObservable<TSource> ElementAtOrDefault<TSource>(this IObservable<TSource> source, int index)
638 {
639 if (source == null)
640 throw new ArgumentNullException("source");
641 if (index < 0)
642 throw new ArgumentOutOfRangeException("index");
643
644 return s_impl.ElementAtOrDefault<TSource>(source, index);
645 }
646
647 #endregion
648
649 #region + FirstAsync +
650
651 /// <summary>
652 /// Returns the first element of an observable sequence.
653 /// </summary>
654 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
655 /// <param name="source">Source observable sequence.</param>
656 /// <returns>Sequence containing the first element in the observable sequence.</returns>
657 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
658 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
659 public static IObservable<TSource> FirstAsync<TSource>(this IObservable<TSource> source)
660 {
661 if (source == null)
662 throw new ArgumentNullException("source");
663
664 return s_impl.FirstAsync<TSource>(source);
665 }
666
667 /// <summary>
668 /// Returns the first element of an observable sequence that satisfies the condition in the predicate.
669 /// </summary>
670 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
671 /// <param name="source">Source observable sequence.</param>
672 /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
673 /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate.</returns>
674 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
675 /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
676 public static IObservable<TSource> FirstAsync<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
677 {
678 if (source == null)
679 throw new ArgumentNullException("source");
680 if (predicate == null)
681 throw new ArgumentNullException("predicate");
682
683 return s_impl.FirstAsync<TSource>(source, predicate);
684 }
685
686 #endregion
687
688 #region + FirstOrDefaultAsync +
689
690 /// <summary>
691 /// Returns the first element of an observable sequence, or a default value if no such element exists.
692 /// </summary>
693 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
694 /// <param name="source">Source observable sequence.</param>
695 /// <returns>Sequence containing the first element in the observable sequence, or a default value if no such element exists.</returns>
696 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
697 public static IObservable<TSource> FirstOrDefaultAsync<TSource>(this IObservable<TSource> source)
698 {
699 if (source == null)
700 throw new ArgumentNullException("source");
701
702 return s_impl.FirstOrDefaultAsync<TSource>(source);
703 }
704
705 /// <summary>
706 /// Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
707 /// </summary>
708 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
709 /// <param name="source">Source observable sequence.</param>
710 /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
711 /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
712 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
713 public static IObservable<TSource> FirstOrDefaultAsync<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
714 {
715 if (source == null)
716 throw new ArgumentNullException("source");
717 if (predicate == null)
718 throw new ArgumentNullException("predicate");
719
720 return s_impl.FirstOrDefaultAsync<TSource>(source, predicate);
721 }
722
723 #endregion
724
725 #region + IsEmpty +
726
727 /// <summary>
728 /// Determines whether an observable sequence is empty.
729 /// </summary>
730 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
731 /// <param name="source">An observable sequence to check for emptiness.</param>
732 /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
733 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
734 public static IObservable<bool> IsEmpty<TSource>(this IObservable<TSource> source)
735 {
736 if (source == null)
737 throw new ArgumentNullException("source");
738
739 return s_impl.IsEmpty<TSource>(source);
740 }
741
742 #endregion
743
744 #region + LastAsync +
745
746 /// <summary>
747 /// Returns the last element of an observable sequence.
748 /// </summary>
749 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
750 /// <param name="source">Source observable sequence.</param>
751 /// <returns>Sequence containing the last element in the observable sequence.</returns>
752 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
753 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
754 public static IObservable<TSource> LastAsync<TSource>(this IObservable<TSource> source)
755 {
756 if (source == null)
757 throw new ArgumentNullException("source");
758
759 return s_impl.LastAsync<TSource>(source);
760 }
761
762 /// <summary>
763 /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
764 /// </summary>
765 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
766 /// <param name="source">Source observable sequence.</param>
767 /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
768 /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
769 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
770 /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
771 public static IObservable<TSource> LastAsync<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
772 {
773 if (source == null)
774 throw new ArgumentNullException("source");
775 if (predicate == null)
776 throw new ArgumentNullException("predicate");
777
778 return s_impl.LastAsync<TSource>(source, predicate);
779 }
780
781 #endregion
782
783 #region + LastOrDefaultAsync +
784
785 /// <summary>
786 /// Returns the last element of an observable sequence, or a default value if no such element exists.
787 /// </summary>
788 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
789 /// <param name="source">Source observable sequence.</param>
790 /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
791 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
792 public static IObservable<TSource> LastOrDefaultAsync<TSource>(this IObservable<TSource> source)
793 {
794 if (source == null)
795 throw new ArgumentNullException("source");
796
797 return s_impl.LastOrDefaultAsync<TSource>(source);
798 }
799
800 /// <summary>
801 /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
802 /// </summary>
803 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
804 /// <param name="source">Source observable sequence.</param>
805 /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
806 /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
807 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
808 public static IObservable<TSource> LastOrDefaultAsync<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
809 {
810 if (source == null)
811 throw new ArgumentNullException("source");
812 if (predicate == null)
813 throw new ArgumentNullException("predicate");
814
815 return s_impl.LastOrDefaultAsync<TSource>(source, predicate);
816 }
817
818 #endregion
819
820 #region + LongCount +
821
822 /// <summary>
823 /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents the total number of elements in an observable sequence.
824 /// </summary>
825 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
826 /// <param name="source">An observable sequence that contains elements to be counted.</param>
827 /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
828 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
829 /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
830 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
831 public static IObservable<long> LongCount<TSource>(this IObservable<TSource> source)
832 {
833 if (source == null)
834 throw new ArgumentNullException("source");
835
836 return s_impl.LongCount<TSource>(source);
837 }
838
839 /// <summary>
840 /// Returns an observable sequence containing an <see cref="T:System.Int64" /> that represents how many elements in the specified observable sequence satisfy a condition.
841 /// </summary>
842 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
843 /// <param name="source">An observable sequence that contains elements to be counted.</param>
844 /// <param name="predicate">A function to test each element for a condition.</param>
845 /// <returns>An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function.</returns>
846 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
847 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
848 public static IObservable<long> LongCount<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
849 {
850 if (source == null)
851 throw new ArgumentNullException("source");
852 if (predicate == null)
853 throw new ArgumentNullException("predicate");
854
855 return s_impl.LongCount<TSource>(source, predicate);
856 }
857
858 #endregion
859
860 #region + Max +
861
862 /// <summary>
863 /// Returns the maximum element in an observable sequence.
864 /// </summary>
865 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
866 /// <param name="source">An observable sequence to determine the maximum element of.</param>
867 /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
868 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
869 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
870 public static IObservable<TSource> Max<TSource>(this IObservable<TSource> source)
871 {
872 if (source == null)
873 throw new ArgumentNullException("source");
874
875 return s_impl.Max<TSource>(source);
876 }
877
878 /// <summary>
879 /// Returns the maximum value in an observable sequence according to the specified comparer.
880 /// </summary>
881 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
882 /// <param name="source">An observable sequence to determine the maximum element of.</param>
883 /// <param name="comparer">Comparer used to compare elements.</param>
884 /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
885 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="comparer"/> is null.</exception>
886 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
887 public static IObservable<TSource> Max<TSource>(this IObservable<TSource> source, IComparer<TSource> comparer)
888 {
889 if (source == null)
890 throw new ArgumentNullException("source");
891 if (comparer == null)
892 throw new ArgumentNullException("comparer");
893
894 return s_impl.Max<TSource>(source, comparer);
895 }
896
897 /// <summary>
898 /// Returns the maximum value in an observable sequence of <see cref="T:System.Double" /> values.
899 /// </summary>
900 /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the maximum value of.</param>
901 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
902 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
903 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
904 public static IObservable<double> Max(this IObservable<double> source)
905 {
906 if (source == null)
907 throw new ArgumentNullException("source");
908
909 return s_impl.Max(source);
910 }
911
912 /// <summary>
913 /// Returns the maximum value in an observable sequence of <see cref="T:System.Single" /> values.
914 /// </summary>
915 /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the maximum value of.</param>
916 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
917 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
918 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
919 public static IObservable<float> Max(this IObservable<float> source)
920 {
921 if (source == null)
922 throw new ArgumentNullException("source");
923
924 return s_impl.Max(source);
925 }
926
927 /// <summary>
928 /// Returns the maximum value in an observable sequence of <see cref="T:System.Decimal" /> values.
929 /// </summary>
930 /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
931 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
932 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
933 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
934 public static IObservable<decimal> Max(this IObservable<decimal> source)
935 {
936 if (source == null)
937 throw new ArgumentNullException("source");
938
939 return s_impl.Max(source);
940 }
941
942 /// <summary>
943 /// Returns the maximum value in an observable sequence of <see cref="T:System.Int32" /> values.
944 /// </summary>
945 /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
946 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
947 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
948 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
949 public static IObservable<int> Max(this IObservable<int> source)
950 {
951 if (source == null)
952 throw new ArgumentNullException("source");
953
954 return s_impl.Max(source);
955 }
956
957 /// <summary>
958 /// Returns the maximum value in an observable sequence of <see cref="T:System.Int64" /> values.
959 /// </summary>
960 /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
961 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
962 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
963 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
964 public static IObservable<long> Max(this IObservable<long> source)
965 {
966 if (source == null)
967 throw new ArgumentNullException("source");
968
969 return s_impl.Max(source);
970 }
971
972 /// <summary>
973 /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
974 /// </summary>
975 /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the maximum value of.</param>
976 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
977 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
978 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
979 public static IObservable<double?> Max(this IObservable<double?> source)
980 {
981 if (source == null)
982 throw new ArgumentNullException("source");
983
984 return s_impl.Max(source);
985 }
986
987 /// <summary>
988 /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
989 /// </summary>
990 /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the maximum value of.</param>
991 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
992 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
993 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
994 public static IObservable<float?> Max(this IObservable<float?> source)
995 {
996 if (source == null)
997 throw new ArgumentNullException("source");
998
999 return s_impl.Max(source);
1000 }
1001
1002 /// <summary>
1003 /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
1004 /// </summary>
1005 /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the maximum value of.</param>
1006 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
1007 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1008 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1009 public static IObservable<decimal?> Max(this IObservable<decimal?> source)
1010 {
1011 if (source == null)
1012 throw new ArgumentNullException("source");
1013
1014 return s_impl.Max(source);
1015 }
1016
1017 /// <summary>
1018 /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
1019 /// </summary>
1020 /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the maximum value of.</param>
1021 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
1022 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1023 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1024 public static IObservable<int?> Max(this IObservable<int?> source)
1025 {
1026 if (source == null)
1027 throw new ArgumentNullException("source");
1028
1029 return s_impl.Max(source);
1030 }
1031
1032 /// <summary>
1033 /// Returns the maximum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
1034 /// </summary>
1035 /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the maximum value of.</param>
1036 /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
1037 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1038 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1039 public static IObservable<long?> Max(this IObservable<long?> source)
1040 {
1041 if (source == null)
1042 throw new ArgumentNullException("source");
1043
1044 return s_impl.Max(source);
1045 }
1046
1047 /// <summary>
1048 /// Invokes a transform function on each element of a sequence and returns the maximum value.
1049 /// </summary>
1050 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1051 /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
1052 /// <param name="source">An observable sequence to determine the mimimum element of.</param>
1053 /// <param name="selector">A transform function to apply to each element.</param>
1054 /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
1055 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1056 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1057 public static IObservable<TResult> Max<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector)
1058 {
1059 if (source == null)
1060 throw new ArgumentNullException("source");
1061 if (selector == null)
1062 throw new ArgumentNullException("selector");
1063
1064 return s_impl.Max<TSource, TResult>(source, selector);
1065 }
1066
1067 /// <summary>
1068 /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
1069 /// </summary>
1070 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1071 /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
1072 /// <param name="source">An observable sequence to determine the mimimum element of.</param>
1073 /// <param name="selector">A transform function to apply to each element.</param>
1074 /// <param name="comparer">Comparer used to compare elements.</param>
1075 /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
1076 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> or <paramref name="comparer"/> is null.</exception>
1077 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1078 public static IObservable<TResult> Max<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector, IComparer<TResult> comparer)
1079 {
1080 if (source == null)
1081 throw new ArgumentNullException("source");
1082 if (selector == null)
1083 throw new ArgumentNullException("selector");
1084 if (comparer == null)
1085 throw new ArgumentNullException("comparer");
1086
1087 return s_impl.Max<TSource, TResult>(source, selector, comparer);
1088 }
1089
1090 /// <summary>
1091 /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Double" /> value.
1092 /// </summary>
1093 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1094 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1095 /// <param name="selector">A transform function to apply to each element.</param>
1096 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Double" /> that corresponds to the maximum value in the source sequence.</returns>
1097 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1098 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1099 public static IObservable<double> Max<TSource>(this IObservable<TSource> source, Func<TSource, double> selector)
1100 {
1101 if (source == null)
1102 throw new ArgumentNullException("source");
1103 if (selector == null)
1104 throw new ArgumentNullException("selector");
1105
1106 return s_impl.Max<TSource>(source, selector);
1107 }
1108
1109 /// <summary>
1110 /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Single" /> value.
1111 /// </summary>
1112 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1113 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1114 /// <param name="selector">A transform function to apply to each element.</param>
1115 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Single" /> that corresponds to the maximum value in the source sequence.</returns>
1116 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1117 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1118 public static IObservable<float> Max<TSource>(this IObservable<TSource> source, Func<TSource, float> selector)
1119 {
1120 if (source == null)
1121 throw new ArgumentNullException("source");
1122 if (selector == null)
1123 throw new ArgumentNullException("selector");
1124
1125 return s_impl.Max<TSource>(source, selector);
1126 }
1127
1128 /// <summary>
1129 /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Decimal" /> value.
1130 /// </summary>
1131 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1132 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1133 /// <param name="selector">A transform function to apply to each element.</param>
1134 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Decimal" /> that corresponds to the maximum value in the source sequence.</returns>
1135 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1136 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1137 public static IObservable<decimal> Max<TSource>(this IObservable<TSource> source, Func<TSource, decimal> selector)
1138 {
1139 if (source == null)
1140 throw new ArgumentNullException("source");
1141 if (selector == null)
1142 throw new ArgumentNullException("selector");
1143
1144 return s_impl.Max<TSource>(source, selector);
1145 }
1146
1147 /// <summary>
1148 /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int32" /> value.
1149 /// </summary>
1150 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1151 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1152 /// <param name="selector">A transform function to apply to each element.</param>
1153 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the maximum value in the source sequence.</returns>
1154 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1155 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1156 public static IObservable<int> Max<TSource>(this IObservable<TSource> source, Func<TSource, int> selector)
1157 {
1158 if (source == null)
1159 throw new ArgumentNullException("source");
1160 if (selector == null)
1161 throw new ArgumentNullException("selector");
1162
1163 return s_impl.Max<TSource>(source, selector);
1164 }
1165
1166 /// <summary>
1167 /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="T:System.Int64" /> value.
1168 /// </summary>
1169 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1170 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1171 /// <param name="selector">A transform function to apply to each element.</param>
1172 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int64" /> that corresponds to the maximum value in the source sequence.</returns>
1173 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1174 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1175 public static IObservable<long> Max<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)
1176 {
1177 if (source == null)
1178 throw new ArgumentNullException("source");
1179 if (selector == null)
1180 throw new ArgumentNullException("selector");
1181
1182 return s_impl.Max<TSource>(source, selector);
1183 }
1184
1185 /// <summary>
1186 /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Double" /> value.
1187 /// </summary>
1188 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1189 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1190 /// <param name="selector">A transform function to apply to each element.</param>
1191 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Double&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
1192 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1193 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1194 public static IObservable<double?> Max<TSource>(this IObservable<TSource> source, Func<TSource, double?> selector)
1195 {
1196 if (source == null)
1197 throw new ArgumentNullException("source");
1198 if (selector == null)
1199 throw new ArgumentNullException("selector");
1200
1201 return s_impl.Max<TSource>(source, selector);
1202 }
1203
1204 /// <summary>
1205 /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Single" /> value.
1206 /// </summary>
1207 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1208 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1209 /// <param name="selector">A transform function to apply to each element.</param>
1210 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Single&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
1211 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1212 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1213 public static IObservable<float?> Max<TSource>(this IObservable<TSource> source, Func<TSource, float?> selector)
1214 {
1215 if (source == null)
1216 throw new ArgumentNullException("source");
1217 if (selector == null)
1218 throw new ArgumentNullException("selector");
1219
1220 return s_impl.Max<TSource>(source, selector);
1221 }
1222
1223 /// <summary>
1224 /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Decimal" /> value.
1225 /// </summary>
1226 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1227 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1228 /// <param name="selector">A transform function to apply to each element.</param>
1229 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Decimal&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
1230 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1231 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1232 public static IObservable<decimal?> Max<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)
1233 {
1234 if (source == null)
1235 throw new ArgumentNullException("source");
1236 if (selector == null)
1237 throw new ArgumentNullException("selector");
1238
1239 return s_impl.Max<TSource>(source, selector);
1240 }
1241
1242 /// <summary>
1243 /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int32" /> value.
1244 /// </summary>
1245 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1246 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1247 /// <param name="selector">A transform function to apply to each element.</param>
1248 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int32&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
1249 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1250 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1251 public static IObservable<int?> Max<TSource>(this IObservable<TSource> source, Func<TSource, int?> selector)
1252 {
1253 if (source == null)
1254 throw new ArgumentNullException("source");
1255 if (selector == null)
1256 throw new ArgumentNullException("selector");
1257
1258 return s_impl.Max<TSource>(source, selector);
1259 }
1260
1261 /// <summary>
1262 /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="T:System.Int64" /> value.
1263 /// </summary>
1264 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1265 /// <param name="source">A sequence of values to determine the maximum value of.</param>
1266 /// <param name="selector">A transform function to apply to each element.</param>
1267 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int64&gt;" /> that corresponds to the maximum value in the source sequence.</returns>
1268 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1269 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1270 public static IObservable<long?> Max<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)
1271 {
1272 if (source == null)
1273 throw new ArgumentNullException("source");
1274 if (selector == null)
1275 throw new ArgumentNullException("selector");
1276
1277 return s_impl.Max<TSource>(source, selector);
1278 }
1279
1280 #endregion
1281
1282 #region + MaxBy +
1283
1284 /// <summary>
1285 /// Returns the elements in an observable sequence with the maximum key value.
1286 /// </summary>
1287 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1288 /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
1289 /// <param name="source">An observable sequence to get the maximum elements for.</param>
1290 /// <param name="keySelector">Key selector function.</param>
1291 /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
1292 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
1293 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1294 public static IObservable<IList<TSource>> MaxBy<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
1295 {
1296 if (source == null)
1297 throw new ArgumentNullException("source");
1298 if (keySelector == null)
1299 throw new ArgumentNullException("keySelector");
1300
1301 return s_impl.MaxBy<TSource, TKey>(source, keySelector);
1302 }
1303
1304 /// <summary>
1305 /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
1306 /// </summary>
1307 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1308 /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
1309 /// <param name="source">An observable sequence to get the maximum elements for.</param>
1310 /// <param name="keySelector">Key selector function.</param>
1311 /// <param name="comparer">Comparer used to compare key values.</param>
1312 /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
1313 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="comparer"/> is null.</exception>
1314 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1315 public static IObservable<IList<TSource>> MaxBy<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
1316 {
1317 if (source == null)
1318 throw new ArgumentNullException("source");
1319 if (keySelector == null)
1320 throw new ArgumentNullException("keySelector");
1321 if (comparer == null)
1322 throw new ArgumentNullException("comparer");
1323
1324 return s_impl.MaxBy<TSource, TKey>(source, keySelector, comparer);
1325 }
1326
1327 #endregion
1328
1329 #region + Min +
1330
1331 /// <summary>
1332 /// Returns the minimum element in an observable sequence.
1333 /// </summary>
1334 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1335 /// <param name="source">An observable sequence to determine the mimimum element of.</param>
1336 /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
1337 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1338 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1339 public static IObservable<TSource> Min<TSource>(this IObservable<TSource> source)
1340 {
1341 if (source == null)
1342 throw new ArgumentNullException("source");
1343
1344 return s_impl.Min<TSource>(source);
1345 }
1346
1347 /// <summary>
1348 /// Returns the minimum element in an observable sequence according to the specified comparer.
1349 /// </summary>
1350 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1351 /// <param name="source">An observable sequence to determine the mimimum element of.</param>
1352 /// <param name="comparer">Comparer used to compare elements.</param>
1353 /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
1354 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="comparer"/> is null.</exception>
1355 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1356 public static IObservable<TSource> Min<TSource>(this IObservable<TSource> source, IComparer<TSource> comparer)
1357 {
1358 if (source == null)
1359 throw new ArgumentNullException("source");
1360 if (comparer == null)
1361 throw new ArgumentNullException("comparer");
1362
1363 return s_impl.Min<TSource>(source, comparer);
1364 }
1365
1366 /// <summary>
1367 /// Returns the minimum value in an observable sequence of <see cref="T:System.Double" /> values.
1368 /// </summary>
1369 /// <param name="source">A sequence of <see cref="T:System.Double" /> values to determine the minimum value of.</param>
1370 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1371 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1372 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1373 public static IObservable<double> Min(this IObservable<double> source)
1374 {
1375 if (source == null)
1376 throw new ArgumentNullException("source");
1377
1378 return s_impl.Min(source);
1379 }
1380
1381 /// <summary>
1382 /// Returns the minimum value in an observable sequence of <see cref="T:System.Single" /> values.
1383 /// </summary>
1384 /// <param name="source">A sequence of <see cref="T:System.Single" /> values to determine the minimum value of.</param>
1385 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1386 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1387 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1388 public static IObservable<float> Min(this IObservable<float> source)
1389 {
1390 if (source == null)
1391 throw new ArgumentNullException("source");
1392
1393 return s_impl.Min(source);
1394 }
1395
1396 /// <summary>
1397 /// Returns the minimum value in an observable sequence of <see cref="T:System.Decimal" /> values.
1398 /// </summary>
1399 /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
1400 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1401 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1402 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1403 public static IObservable<decimal> Min(this IObservable<decimal> source)
1404 {
1405 if (source == null)
1406 throw new ArgumentNullException("source");
1407
1408 return s_impl.Min(source);
1409 }
1410
1411 /// <summary>
1412 /// Returns the minimum value in an observable sequence of <see cref="T:System.Int32" /> values.
1413 /// </summary>
1414 /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
1415 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1416 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1417 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1418 public static IObservable<int> Min(this IObservable<int> source)
1419 {
1420 if (source == null)
1421 throw new ArgumentNullException("source");
1422
1423 return s_impl.Min(source);
1424 }
1425
1426 /// <summary>
1427 /// Returns the minimum value in an observable sequence of <see cref="T:System.Int64" /> values.
1428 /// </summary>
1429 /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
1430 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1431 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1432 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1433 public static IObservable<long> Min(this IObservable<long> source)
1434 {
1435 if (source == null)
1436 throw new ArgumentNullException("source");
1437
1438 return s_impl.Min(source);
1439 }
1440
1441 /// <summary>
1442 /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Double" /> values.
1443 /// </summary>
1444 /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to determine the minimum value of.</param>
1445 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1446 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1447 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1448 public static IObservable<double?> Min(this IObservable<double?> source)
1449 {
1450 if (source == null)
1451 throw new ArgumentNullException("source");
1452
1453 return s_impl.Min(source);
1454 }
1455
1456 /// <summary>
1457 /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Single" /> values.
1458 /// </summary>
1459 /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to determine the minimum value of.</param>
1460 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1461 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1462 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1463 public static IObservable<float?> Min(this IObservable<float?> source)
1464 {
1465 if (source == null)
1466 throw new ArgumentNullException("source");
1467
1468 return s_impl.Min(source);
1469 }
1470
1471 /// <summary>
1472 /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Decimal" /> values.
1473 /// </summary>
1474 /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to determine the minimum value of.</param>
1475 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1476 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1477 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1478 public static IObservable<decimal?> Min(this IObservable<decimal?> source)
1479 {
1480 if (source == null)
1481 throw new ArgumentNullException("source");
1482
1483 return s_impl.Min(source);
1484 }
1485
1486 /// <summary>
1487 /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int32" /> values.
1488 /// </summary>
1489 /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to determine the minimum value of.</param>
1490 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1491 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1492 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1493 public static IObservable<int?> Min(this IObservable<int?> source)
1494 {
1495 if (source == null)
1496 throw new ArgumentNullException("source");
1497
1498 return s_impl.Min(source);
1499 }
1500
1501 /// <summary>
1502 /// Returns the minimum value in an observable sequence of nullable <see cref="T:System.Int64" /> values.
1503 /// </summary>
1504 /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to determine the minimum value of.</param>
1505 /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
1506 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1507 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1508 public static IObservable<long?> Min(this IObservable<long?> source)
1509 {
1510 if (source == null)
1511 throw new ArgumentNullException("source");
1512
1513 return s_impl.Min(source);
1514 }
1515
1516 /// <summary>
1517 /// Invokes a transform function on each element of a sequence and returns the minimum value.
1518 /// </summary>
1519 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1520 /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
1521 /// <param name="source">An observable sequence to determine the mimimum element of.</param>
1522 /// <param name="selector">A transform function to apply to each element.</param>
1523 /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
1524 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1525 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1526 public static IObservable<TResult> Min<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector)
1527 {
1528 if (source == null)
1529 throw new ArgumentNullException("source");
1530 if (selector == null)
1531 throw new ArgumentNullException("selector");
1532
1533 return s_impl.Min<TSource, TResult>(source, selector);
1534 }
1535
1536 /// <summary>
1537 /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
1538 /// </summary>
1539 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1540 /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
1541 /// <param name="source">An observable sequence to determine the mimimum element of.</param>
1542 /// <param name="selector">A transform function to apply to each element.</param>
1543 /// <param name="comparer">Comparer used to compare elements.</param>
1544 /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
1545 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> or <paramref name="comparer"/> is null.</exception>
1546 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1547 public static IObservable<TResult> Min<TSource, TResult>(this IObservable<TSource> source, Func<TSource, TResult> selector, IComparer<TResult> comparer)
1548 {
1549 if (source == null)
1550 throw new ArgumentNullException("source");
1551 if (selector == null)
1552 throw new ArgumentNullException("selector");
1553 if (comparer == null)
1554 throw new ArgumentNullException("comparer");
1555
1556 return s_impl.Min<TSource, TResult>(source, selector, comparer);
1557 }
1558
1559 /// <summary>
1560 /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Double" /> value.
1561 /// </summary>
1562 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1563 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1564 /// <param name="selector">A transform function to apply to each element.</param>
1565 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Double" /> that corresponds to the minimum value in the source sequence.</returns>
1566 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1567 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1568 public static IObservable<double> Min<TSource>(this IObservable<TSource> source, Func<TSource, double> selector)
1569 {
1570 if (source == null)
1571 throw new ArgumentNullException("source");
1572 if (selector == null)
1573 throw new ArgumentNullException("selector");
1574
1575 return s_impl.Min<TSource>(source, selector);
1576 }
1577
1578 /// <summary>
1579 /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Single" /> value.
1580 /// </summary>
1581 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1582 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1583 /// <param name="selector">A transform function to apply to each element.</param>
1584 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Single" /> that corresponds to the minimum value in the source sequence.</returns>
1585 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1586 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1587 public static IObservable<float> Min<TSource>(this IObservable<TSource> source, Func<TSource, float> selector)
1588 {
1589 if (source == null)
1590 throw new ArgumentNullException("source");
1591 if (selector == null)
1592 throw new ArgumentNullException("selector");
1593
1594 return s_impl.Min<TSource>(source, selector);
1595 }
1596
1597 /// <summary>
1598 /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Decimal" /> value.
1599 /// </summary>
1600 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1601 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1602 /// <param name="selector">A transform function to apply to each element.</param>
1603 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Decimal" /> that corresponds to the minimum value in the source sequence.</returns>
1604 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1605 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1606 public static IObservable<decimal> Min<TSource>(this IObservable<TSource> source, Func<TSource, decimal> selector)
1607 {
1608 if (source == null)
1609 throw new ArgumentNullException("source");
1610 if (selector == null)
1611 throw new ArgumentNullException("selector");
1612
1613 return s_impl.Min<TSource>(source, selector);
1614 }
1615
1616 /// <summary>
1617 /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int32" /> value.
1618 /// </summary>
1619 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1620 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1621 /// <param name="selector">A transform function to apply to each element.</param>
1622 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int32" /> that corresponds to the minimum value in the source sequence.</returns>
1623 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1624 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1625 public static IObservable<int> Min<TSource>(this IObservable<TSource> source, Func<TSource, int> selector)
1626 {
1627 if (source == null)
1628 throw new ArgumentNullException("source");
1629 if (selector == null)
1630 throw new ArgumentNullException("selector");
1631
1632 return s_impl.Min<TSource>(source, selector);
1633 }
1634
1635 /// <summary>
1636 /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="T:System.Int64" /> value.
1637 /// </summary>
1638 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1639 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1640 /// <param name="selector">A transform function to apply to each element.</param>
1641 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Int64" /> that corresponds to the minimum value in the source sequence.</returns>
1642 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1643 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1644 public static IObservable<long> Min<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)
1645 {
1646 if (source == null)
1647 throw new ArgumentNullException("source");
1648 if (selector == null)
1649 throw new ArgumentNullException("selector");
1650
1651 return s_impl.Min<TSource>(source, selector);
1652 }
1653
1654 /// <summary>
1655 /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Double" /> value.
1656 /// </summary>
1657 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1658 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1659 /// <param name="selector">A transform function to apply to each element.</param>
1660 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Double&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
1661 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1662 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1663 public static IObservable<double?> Min<TSource>(this IObservable<TSource> source, Func<TSource, double?> selector)
1664 {
1665 if (source == null)
1666 throw new ArgumentNullException("source");
1667 if (selector == null)
1668 throw new ArgumentNullException("selector");
1669
1670 return s_impl.Min<TSource>(source, selector);
1671 }
1672
1673 /// <summary>
1674 /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Single" /> value.
1675 /// </summary>
1676 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1677 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1678 /// <param name="selector">A transform function to apply to each element.</param>
1679 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Single&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
1680 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1681 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1682 public static IObservable<float?> Min<TSource>(this IObservable<TSource> source, Func<TSource, float?> selector)
1683 {
1684 if (source == null)
1685 throw new ArgumentNullException("source");
1686 if (selector == null)
1687 throw new ArgumentNullException("selector");
1688
1689 return s_impl.Min<TSource>(source, selector);
1690 }
1691
1692 /// <summary>
1693 /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Decimal" /> value.
1694 /// </summary>
1695 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1696 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1697 /// <param name="selector">A transform function to apply to each element.</param>
1698 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Decimal&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
1699 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1700 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1701 public static IObservable<decimal?> Min<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)
1702 {
1703 if (source == null)
1704 throw new ArgumentNullException("source");
1705 if (selector == null)
1706 throw new ArgumentNullException("selector");
1707
1708 return s_impl.Min<TSource>(source, selector);
1709 }
1710
1711 /// <summary>
1712 /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int32" /> value.
1713 /// </summary>
1714 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1715 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1716 /// <param name="selector">A transform function to apply to each element.</param>
1717 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int32&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
1718 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1719 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1720 public static IObservable<int?> Min<TSource>(this IObservable<TSource> source, Func<TSource, int?> selector)
1721 {
1722 if (source == null)
1723 throw new ArgumentNullException("source");
1724 if (selector == null)
1725 throw new ArgumentNullException("selector");
1726
1727 return s_impl.Min<TSource>(source, selector);
1728 }
1729
1730 /// <summary>
1731 /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="T:System.Int64" /> value.
1732 /// </summary>
1733 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1734 /// <param name="source">A sequence of values to determine the minimum value of.</param>
1735 /// <param name="selector">A transform function to apply to each element.</param>
1736 /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable&lt;System.Int64&gt;" /> that corresponds to the minimum value in the source sequence.</returns>
1737 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
1738 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1739 public static IObservable<long?> Min<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)
1740 {
1741 if (source == null)
1742 throw new ArgumentNullException("source");
1743 if (selector == null)
1744 throw new ArgumentNullException("selector");
1745
1746 return s_impl.Min<TSource>(source, selector);
1747 }
1748
1749 #endregion
1750
1751 #region + MinBy +
1752
1753 /// <summary>
1754 /// Returns the elements in an observable sequence with the minimum key value.
1755 /// </summary>
1756 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1757 /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
1758 /// <param name="source">An observable sequence to get the minimum elements for.</param>
1759 /// <param name="keySelector">Key selector function.</param>
1760 /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
1761 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
1762 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1763 public static IObservable<IList<TSource>> MinBy<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
1764 {
1765 if (source == null)
1766 throw new ArgumentNullException("source");
1767 if (keySelector == null)
1768 throw new ArgumentNullException("keySelector");
1769
1770 return s_impl.MinBy<TSource, TKey>(source, keySelector);
1771 }
1772
1773 /// <summary>
1774 /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
1775 /// </summary>
1776 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1777 /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
1778 /// <param name="source">An observable sequence to get the minimum elements for.</param>
1779 /// <param name="keySelector">Key selector function.</param>
1780 /// <param name="comparer">Comparer used to compare key values.</param>
1781 /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
1782 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="comparer"/> is null.</exception>
1783 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1784 public static IObservable<IList<TSource>> MinBy<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
1785 {
1786 if (source == null)
1787 throw new ArgumentNullException("source");
1788 if (keySelector == null)
1789 throw new ArgumentNullException("keySelector");
1790 if (comparer == null)
1791 throw new ArgumentNullException("comparer");
1792
1793 return s_impl.MinBy<TSource, TKey>(source, keySelector, comparer);
1794 }
1795
1796 #endregion
1797
1798 #region + SequenceEqual +
1799
1800 /// <summary>
1801 /// Determines whether two sequences are equal by comparing the elements pairwise.
1802 /// </summary>
1803 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1804 /// <param name="first">First observable sequence to compare.</param>
1805 /// <param name="second">Second observable sequence to compare.</param>
1806 /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type.</returns>
1807 /// <exception cref="ArgumentNullException"><paramref name="first"/> or <paramref name="second"/> is null.</exception>
1808 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1809 public static IObservable<bool> SequenceEqual<TSource>(this IObservable<TSource> first, IObservable<TSource> second)
1810 {
1811 if (first == null)
1812 throw new ArgumentNullException("first");
1813 if (second == null)
1814 throw new ArgumentNullException("second");
1815
1816 return s_impl.SequenceEqual<TSource>(first, second);
1817 }
1818
1819 /// <summary>
1820 /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
1821 /// </summary>
1822 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1823 /// <param name="first">First observable sequence to compare.</param>
1824 /// <param name="second">Second observable sequence to compare.</param>
1825 /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
1826 /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.</returns>
1827 /// <exception cref="ArgumentNullException"><paramref name="first"/> or <paramref name="second"/> or <paramref name="comparer"/> is null.</exception>
1828 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1829 public static IObservable<bool> SequenceEqual<TSource>(this IObservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
1830 {
1831 if (first == null)
1832 throw new ArgumentNullException("first");
1833 if (second == null)
1834 throw new ArgumentNullException("second");
1835 if (comparer == null)
1836 throw new ArgumentNullException("comparer");
1837
1838 return s_impl.SequenceEqual<TSource>(first, second, comparer);
1839 }
1840
1841 /// <summary>
1842 /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
1843 /// </summary>
1844 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1845 /// <param name="first">First observable sequence to compare.</param>
1846 /// <param name="second">Second observable sequence to compare.</param>
1847 /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type.</returns>
1848 /// <exception cref="ArgumentNullException"><paramref name="first"/> or <paramref name="second"/> is null.</exception>
1849 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1850 public static IObservable<bool> SequenceEqual<TSource>(this IObservable<TSource> first, IEnumerable<TSource> second)
1851 {
1852 if (first == null)
1853 throw new ArgumentNullException("first");
1854 if (second == null)
1855 throw new ArgumentNullException("second");
1856
1857 return s_impl.SequenceEqual<TSource>(first, second);
1858 }
1859
1860 /// <summary>
1861 /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
1862 /// </summary>
1863 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1864 /// <param name="first">First observable sequence to compare.</param>
1865 /// <param name="second">Second observable sequence to compare.</param>
1866 /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
1867 /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.</returns>
1868 /// <exception cref="ArgumentNullException"><paramref name="first"/> or <paramref name="second"/> or <paramref name="comparer"/> is null.</exception>
1869 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1870 public static IObservable<bool> SequenceEqual<TSource>(this IObservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
1871 {
1872 if (first == null)
1873 throw new ArgumentNullException("first");
1874 if (second == null)
1875 throw new ArgumentNullException("second");
1876 if (comparer == null)
1877 throw new ArgumentNullException("comparer");
1878
1879 return s_impl.SequenceEqual<TSource>(first, second, comparer);
1880 }
1881
1882 #endregion
1883
1884 #region + SingleAsync +
1885
1886 /// <summary>
1887 /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
1888 /// </summary>
1889 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1890 /// <param name="source">Source observable sequence.</param>
1891 /// <returns>Sequence containing the single element in the observable sequence.</returns>
1892 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1893 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
1894 public static IObservable<TSource> SingleAsync<TSource>(this IObservable<TSource> source)
1895 {
1896 if (source == null)
1897 throw new ArgumentNullException("source");
1898
1899 return s_impl.SingleAsync<TSource>(source);
1900 }
1901
1902 /// <summary>
1903 /// Returns the only element of an observable sequence that satisfies the condition in the predicate, and reports an exception if there is not exactly one element in the observable sequence.
1904 /// </summary>
1905 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1906 /// <param name="source">Source observable sequence.</param>
1907 /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
1908 /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
1909 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
1910 /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- More than one element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
1911 public static IObservable<TSource> SingleAsync<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
1912 {
1913 if (source == null)
1914 throw new ArgumentNullException("source");
1915 if (predicate == null)
1916 throw new ArgumentNullException("predicate");
1917
1918 return s_impl.SingleAsync<TSource>(source, predicate);
1919 }
1920
1921 #endregion
1922
1923 #region + SingleOrDefaultAsync +
1924
1925 /// <summary>
1926 /// Returns the only element of an observable sequence, or a default value if the observable sequence is empty; this method reports an exception if there is more than one element in the observable sequence.
1927 /// </summary>
1928 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1929 /// <param name="source">Source observable sequence.</param>
1930 /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
1931 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1932 /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
1933 public static IObservable<TSource> SingleOrDefaultAsync<TSource>(this IObservable<TSource> source)
1934 {
1935 if (source == null)
1936 throw new ArgumentNullException("source");
1937
1938 return s_impl.SingleOrDefaultAsync<TSource>(source);
1939 }
1940
1941 /// <summary>
1942 /// Returns the only element of an observable sequence that matches the predicate, or a default value if no such element exists; this method reports an exception if there is more than one element in the observable sequence.
1943 /// </summary>
1944 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
1945 /// <param name="source">Source observable sequence.</param>
1946 /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
1947 /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
1948 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="predicate"/> is null.</exception>
1949 /// <exception cref="InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
1950 public static IObservable<TSource> SingleOrDefaultAsync<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
1951 {
1952 if (source == null)
1953 throw new ArgumentNullException("source");
1954 if (predicate == null)
1955 throw new ArgumentNullException("predicate");
1956
1957 return s_impl.SingleOrDefaultAsync<TSource>(source, predicate);
1958 }
1959
1960 #endregion
1961
1962 #region + Sum +
1963
1964 /// <summary>
1965 /// Computes the sum of a sequence of <see cref="T:System.Double" /> values.
1966 /// </summary>
1967 /// <param name="source">A sequence of <see cref="T:System.Double" /> values to calculate the sum of.</param>
1968 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
1969 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1970 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1971 public static IObservable<double> Sum(this IObservable<double> source)
1972 {
1973 if (source == null)
1974 throw new ArgumentNullException("source");
1975
1976 return s_impl.Sum(source);
1977 }
1978
1979 /// <summary>
1980 /// Computes the sum of a sequence of <see cref="T:System.Single" /> values.
1981 /// </summary>
1982 /// <param name="source">A sequence of <see cref="T:System.Single" /> values to calculate the sum of.</param>
1983 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
1984 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
1985 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
1986 public static IObservable<float> Sum(this IObservable<float> source)
1987 {
1988 if (source == null)
1989 throw new ArgumentNullException("source");
1990
1991 return s_impl.Sum(source);
1992 }
1993
1994 /// <summary>
1995 /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values.
1996 /// </summary>
1997 /// <param name="source">A sequence of <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
1998 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
1999 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2000 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
2001 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2002 public static IObservable<decimal> Sum(this IObservable<decimal> source)
2003 {
2004 if (source == null)
2005 throw new ArgumentNullException("source");
2006
2007 return s_impl.Sum(source);
2008 }
2009
2010 /// <summary>
2011 /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values.
2012 /// </summary>
2013 /// <param name="source">A sequence of <see cref="T:System.Int32" /> values to calculate the sum of.</param>
2014 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2015 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2016 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue"/>.</exception>
2017 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2018 public static IObservable<int> Sum(this IObservable<int> source)
2019 {
2020 if (source == null)
2021 throw new ArgumentNullException("source");
2022
2023 return s_impl.Sum(source);
2024 }
2025
2026 /// <summary>
2027 /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values.
2028 /// </summary>
2029 /// <param name="source">A sequence of <see cref="T:System.Int64" /> values to calculate the sum of.</param>
2030 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2031 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2032 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
2033 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2034 public static IObservable<long> Sum(this IObservable<long> source)
2035 {
2036 if (source == null)
2037 throw new ArgumentNullException("source");
2038
2039 return s_impl.Sum(source);
2040 }
2041
2042 /// <summary>
2043 /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values.
2044 /// </summary>
2045 /// <param name="source">A sequence of nullable <see cref="T:System.Double" /> values to calculate the sum of.</param>
2046 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2047 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2048 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2049 public static IObservable<double?> Sum(this IObservable<double?> source)
2050 {
2051 if (source == null)
2052 throw new ArgumentNullException("source");
2053
2054 return s_impl.Sum(source);
2055 }
2056
2057 /// <summary>
2058 /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values.
2059 /// </summary>
2060 /// <param name="source">A sequence of nullable <see cref="T:System.Single" /> values to calculate the sum of.</param>
2061 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2062 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2063 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2064 public static IObservable<float?> Sum(this IObservable<float?> source)
2065 {
2066 if (source == null)
2067 throw new ArgumentNullException("source");
2068
2069 return s_impl.Sum(source);
2070 }
2071
2072 /// <summary>
2073 /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values.
2074 /// </summary>
2075 /// <param name="source">A sequence of nullable <see cref="T:System.Decimal" /> values to calculate the sum of.</param>
2076 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2077 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2078 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
2079 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2080 public static IObservable<decimal?> Sum(this IObservable<decimal?> source)
2081 {
2082 if (source == null)
2083 throw new ArgumentNullException("source");
2084
2085 return s_impl.Sum(source);
2086 }
2087
2088 /// <summary>
2089 /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values.
2090 /// </summary>
2091 /// <param name="source">A sequence of nullable <see cref="T:System.Int32" /> values to calculate the sum of.</param>
2092 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2093 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2094 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue"/>.</exception>
2095 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2096 public static IObservable<int?> Sum(this IObservable<int?> source)
2097 {
2098 if (source == null)
2099 throw new ArgumentNullException("source");
2100
2101 return s_impl.Sum(source);
2102 }
2103
2104 /// <summary>
2105 /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values.
2106 /// </summary>
2107 /// <param name="source">A sequence of nullable <see cref="T:System.Int64" /> values to calculate the sum of.</param>
2108 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2109 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2110 /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
2111 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2112 public static IObservable<long?> Sum(this IObservable<long?> source)
2113 {
2114 if (source == null)
2115 throw new ArgumentNullException("source");
2116
2117 return s_impl.Sum(source);
2118 }
2119
2120 /// <summary>
2121 /// Computes the sum of a sequence of <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
2122 /// </summary>
2123 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2124 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2125 /// <param name="selector">A transform function to apply to each element.</param>
2126 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2127 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2128 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2129 public static IObservable<double> Sum<TSource>(this IObservable<TSource> source, Func<TSource, double> selector)
2130 {
2131 if (source == null)
2132 throw new ArgumentNullException("source");
2133 if (selector == null)
2134 throw new ArgumentNullException("selector");
2135
2136 return s_impl.Sum<TSource>(source, selector);
2137 }
2138
2139 /// <summary>
2140 /// Computes the sum of a sequence of <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
2141 /// </summary>
2142 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2143 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2144 /// <param name="selector">A transform function to apply to each element.</param>
2145 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2146 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2147 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2148 public static IObservable<float> Sum<TSource>(this IObservable<TSource> source, Func<TSource, float> selector)
2149 {
2150 if (source == null)
2151 throw new ArgumentNullException("source");
2152 if (selector == null)
2153 throw new ArgumentNullException("selector");
2154
2155 return s_impl.Sum<TSource>(source, selector);
2156 }
2157
2158 /// <summary>
2159 /// Computes the sum of a sequence of <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
2160 /// </summary>
2161 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2162 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2163 /// <param name="selector">A transform function to apply to each element.</param>
2164 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2165 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2166 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
2167 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2168 public static IObservable<decimal> Sum<TSource>(this IObservable<TSource> source, Func<TSource, decimal> selector)
2169 {
2170 if (source == null)
2171 throw new ArgumentNullException("source");
2172 if (selector == null)
2173 throw new ArgumentNullException("selector");
2174
2175 return s_impl.Sum<TSource>(source, selector);
2176 }
2177
2178 /// <summary>
2179 /// Computes the sum of a sequence of <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
2180 /// </summary>
2181 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2182 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2183 /// <param name="selector">A transform function to apply to each element.</param>
2184 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2185 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2186 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue"/>.</exception>
2187 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2188 public static IObservable<int> Sum<TSource>(this IObservable<TSource> source, Func<TSource, int> selector)
2189 {
2190 if (source == null)
2191 throw new ArgumentNullException("source");
2192 if (selector == null)
2193 throw new ArgumentNullException("selector");
2194
2195 return s_impl.Sum<TSource>(source, selector);
2196 }
2197
2198 /// <summary>
2199 /// Computes the sum of a sequence of <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
2200 /// </summary>
2201 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2202 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2203 /// <param name="selector">A transform function to apply to each element.</param>
2204 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2205 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2206 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
2207 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2208 public static IObservable<long> Sum<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)
2209 {
2210 if (source == null)
2211 throw new ArgumentNullException("source");
2212 if (selector == null)
2213 throw new ArgumentNullException("selector");
2214
2215 return s_impl.Sum<TSource>(source, selector);
2216 }
2217
2218 /// <summary>
2219 /// Computes the sum of a sequence of nullable <see cref="T:System.Double" /> values that are obtained by invoking a transform function on each element of the input sequence.
2220 /// </summary>
2221 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2222 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2223 /// <param name="selector">A transform function to apply to each element.</param>
2224 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2225 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2226 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2227 public static IObservable<double?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, double?> selector)
2228 {
2229 if (source == null)
2230 throw new ArgumentNullException("source");
2231 if (selector == null)
2232 throw new ArgumentNullException("selector");
2233
2234 return s_impl.Sum<TSource>(source, selector);
2235 }
2236
2237 /// <summary>
2238 /// Computes the sum of a sequence of nullable <see cref="T:System.Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
2239 /// </summary>
2240 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2241 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2242 /// <param name="selector">A transform function to apply to each element.</param>
2243 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2244 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2245 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2246 public static IObservable<float?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, float?> selector)
2247 {
2248 if (source == null)
2249 throw new ArgumentNullException("source");
2250 if (selector == null)
2251 throw new ArgumentNullException("selector");
2252
2253 return s_impl.Sum<TSource>(source, selector);
2254 }
2255
2256 /// <summary>
2257 /// Computes the sum of a sequence of nullable <see cref="T:System.Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
2258 /// </summary>
2259 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2260 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2261 /// <param name="selector">A transform function to apply to each element.</param>
2262 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2263 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2264 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Decimal.MaxValue"/>.</exception>
2265 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2266 public static IObservable<decimal?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)
2267 {
2268 if (source == null)
2269 throw new ArgumentNullException("source");
2270 if (selector == null)
2271 throw new ArgumentNullException("selector");
2272
2273 return s_impl.Sum<TSource>(source, selector);
2274 }
2275
2276 /// <summary>
2277 /// Computes the sum of a sequence of nullable <see cref="T:System.Int32" /> values that are obtained by invoking a transform function on each element of the input sequence.
2278 /// </summary>
2279 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2280 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2281 /// <param name="selector">A transform function to apply to each element.</param>
2282 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2283 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2284 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int32.MaxValue"/>.</exception>
2285 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2286 public static IObservable<int?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, int?> selector)
2287 {
2288 if (source == null)
2289 throw new ArgumentNullException("source");
2290 if (selector == null)
2291 throw new ArgumentNullException("selector");
2292
2293 return s_impl.Sum<TSource>(source, selector);
2294 }
2295
2296 /// <summary>
2297 /// Computes the sum of a sequence of nullable <see cref="T:System.Int64" /> values that are obtained by invoking a transform function on each element of the input sequence.
2298 /// </summary>
2299 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2300 /// <param name="source">A sequence of values that are used to calculate a sum.</param>
2301 /// <param name="selector">A transform function to apply to each element.</param>
2302 /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
2303 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
2304 /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="M:System.Int64.MaxValue"/>.</exception>
2305 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2306 public static IObservable<long?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)
2307 {
2308 if (source == null)
2309 throw new ArgumentNullException("source");
2310 if (selector == null)
2311 throw new ArgumentNullException("selector");
2312
2313 return s_impl.Sum<TSource>(source, selector);
2314 }
2315
2316 #endregion
2317
2318 #region + ToArray +
2319
2320 /// <summary>
2321 /// Creates an array from an observable sequence.
2322 /// </summary>
2323 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2324 /// <param name="source">The source observable sequence to get an array of elements for.</param>
2325 /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
2326 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2327 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2328 public static IObservable<TSource[]> ToArray<TSource>(this IObservable<TSource> source)
2329 {
2330 if (source == null)
2331 throw new ArgumentNullException("source");
2332
2333 return s_impl.ToArray<TSource>(source);
2334 }
2335
2336 #endregion
2337
2338 #region + ToDictionary +
2339
2340 /// <summary>
2341 /// Creates a dictionary from an observable sequence according to a specified key selector function.
2342 /// </summary>
2343 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2344 /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
2345 /// <param name="source">An observable sequence to create a dictionary for.</param>
2346 /// <param name="keySelector">A function to extract a key from each element.</param>
2347 /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
2348 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
2349 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2350 public static IObservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
2351 {
2352 if (source == null)
2353 throw new ArgumentNullException("source");
2354 if (keySelector == null)
2355 throw new ArgumentNullException("keySelector");
2356
2357 return s_impl.ToDictionary<TSource, TKey>(source, keySelector);
2358 }
2359
2360 /// <summary>
2361 /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
2362 /// </summary>
2363 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2364 /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
2365 /// <param name="source">An observable sequence to create a dictionary for.</param>
2366 /// <param name="keySelector">A function to extract a key from each element.</param>
2367 /// <param name="comparer">An equality comparer to compare keys.</param>
2368 /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
2369 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="comparer"/> is null.</exception>
2370 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2371 public static IObservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
2372 {
2373 if (source == null)
2374 throw new ArgumentNullException("source");
2375 if (keySelector == null)
2376 throw new ArgumentNullException("keySelector");
2377 if (comparer == null)
2378 throw new ArgumentNullException("comparer");
2379
2380 return s_impl.ToDictionary<TSource, TKey>(source, keySelector, comparer);
2381 }
2382
2383 /// <summary>
2384 /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
2385 /// </summary>
2386 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2387 /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
2388 /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
2389 /// <param name="source">An observable sequence to create a dictionary for.</param>
2390 /// <param name="keySelector">A function to extract a key from each element.</param>
2391 /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
2392 /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
2393 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is null.</exception>
2394 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2395 public static IObservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
2396 {
2397 if (source == null)
2398 throw new ArgumentNullException("source");
2399 if (keySelector == null)
2400 throw new ArgumentNullException("keySelector");
2401 if (elementSelector == null)
2402 throw new ArgumentNullException("elementSelector");
2403
2404 return s_impl.ToDictionary<TSource, TKey, TElement>(source, keySelector, elementSelector);
2405 }
2406
2407 /// <summary>
2408 /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
2409 /// </summary>
2410 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2411 /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
2412 /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
2413 /// <param name="source">An observable sequence to create a dictionary for.</param>
2414 /// <param name="keySelector">A function to extract a key from each element.</param>
2415 /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
2416 /// <param name="comparer">An equality comparer to compare keys.</param>
2417 /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
2418 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> or <paramref name="comparer"/> is null.</exception>
2419 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2420 public static IObservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
2421 {
2422 if (source == null)
2423 throw new ArgumentNullException("source");
2424 if (keySelector == null)
2425 throw new ArgumentNullException("keySelector");
2426 if (elementSelector == null)
2427 throw new ArgumentNullException("elementSelector");
2428 if (comparer == null)
2429 throw new ArgumentNullException("comparer");
2430
2431 return s_impl.ToDictionary<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
2432 }
2433
2434 #endregion
2435
2436 #region + ToList +
2437
2438 /// <summary>
2439 /// Creates a list from an observable sequence.
2440 /// </summary>
2441 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2442 /// <param name="source">The source observable sequence to get a list of elements for.</param>
2443 /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
2444 /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
2445 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2446 public static IObservable<IList<TSource>> ToList<TSource>(this IObservable<TSource> source)
2447 {
2448 if (source == null)
2449 throw new ArgumentNullException("source");
2450
2451 return s_impl.ToList<TSource>(source);
2452 }
2453
2454 #endregion
2455
2456 #region + ToLookup +
2457
2458 /// <summary>
2459 /// Creates a lookup from an observable sequence according to a specified key selector function.
2460 /// </summary>
2461 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2462 /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
2463 /// <param name="source">An observable sequence to create a lookup for.</param>
2464 /// <param name="keySelector">A function to extract a key from each element.</param>
2465 /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
2466 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
2467 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2468 public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector)
2469 {
2470 if (source == null)
2471 throw new ArgumentNullException("source");
2472 if (keySelector == null)
2473 throw new ArgumentNullException("keySelector");
2474
2475 return s_impl.ToLookup<TSource, TKey>(source, keySelector);
2476 }
2477
2478 /// <summary>
2479 /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
2480 /// </summary>
2481 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2482 /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
2483 /// <param name="source">An observable sequence to create a lookup for.</param>
2484 /// <param name="keySelector">A function to extract a key from each element.</param>
2485 /// <param name="comparer">An equality comparer to compare keys.</param>
2486 /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
2487 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="comparer"/> is null.</exception>
2488 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2489 public static IObservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
2490 {
2491 if (source == null)
2492 throw new ArgumentNullException("source");
2493 if (keySelector == null)
2494 throw new ArgumentNullException("keySelector");
2495 if (comparer == null)
2496 throw new ArgumentNullException("comparer");
2497
2498 return s_impl.ToLookup<TSource, TKey>(source, keySelector, comparer);
2499 }
2500
2501 /// <summary>
2502 /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
2503 /// </summary>
2504 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2505 /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
2506 /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
2507 /// <param name="source">An observable sequence to create a lookup for.</param>
2508 /// <param name="keySelector">A function to extract a key from each element.</param>
2509 /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
2510 /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
2511 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is null.</exception>
2512 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2513 public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
2514 {
2515 if (source == null)
2516 throw new ArgumentNullException("source");
2517 if (keySelector == null)
2518 throw new ArgumentNullException("keySelector");
2519 if (elementSelector == null)
2520 throw new ArgumentNullException("elementSelector");
2521
2522 return s_impl.ToLookup<TSource, TKey, TElement>(source, keySelector, elementSelector);
2523 }
2524
2525 /// <summary>
2526 /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
2527 /// </summary>
2528 /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
2529 /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
2530 /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
2531 /// <param name="source">An observable sequence to create a lookup for.</param>
2532 /// <param name="keySelector">A function to extract a key from each element.</param>
2533 /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
2534 /// <param name="comparer">An equality comparer to compare keys.</param>
2535 /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
2536 /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> or <paramref name="comparer"/> is null.</exception>
2537 /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
2538 public static IObservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
2539 {
2540 if (source == null)
2541 throw new ArgumentNullException("source");
2542 if (keySelector == null)
2543 throw new ArgumentNullException("keySelector");
2544 if (elementSelector == null)
2545 throw new ArgumentNullException("elementSelector");
2546 if (comparer == null)
2547 throw new ArgumentNullException("comparer");
2548
2549 return s_impl.ToLookup<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
2550 }
2551
2552 #endregion
2553 }
2554 }