Exemplo n.º 1
0
 /// <summary>Returns the first element for which the given function returns true. Returns the default value if no such element exists, or the input stream is empty.</summary>
 /// <param name="predicate">A function to test each source element for a condition.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The first element for which the predicate returns true, or the default value if no such element exists or the input parallel stream is empty.</returns>
 public static T FirstOrDefault <T>(this ParStream <T> stream, Func <T, bool> predicate)
 {
     return(stream.Where(predicate).FirstOrDefault());
 }
Exemplo n.º 2
0
 /// <summary>Filters the elements of the input parallel stream.</summary>
 /// <param name="predicate">A function to test each source element for a condition.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <TSource> Where <TSource>(this ParStream <TSource> stream, Func <TSource, bool> predicate)
 {
     return(CSharpProxy.Where(stream, predicate));
 }
Exemplo n.º 3
0
 /// <summary>Applies a key-generating function to each element of the input parallel stream and yields a parallel stream of unique keys and a sequence of all elements that have each key.</summary>
 /// <param name="projection">A function to transform items of the input parallel stream into comparable keys.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>A parallel stream of IGrouping.</returns>
 public static ParStream <System.Linq.IGrouping <TKey, TSource> > GroupBy <TSource, TKey>(this ParStream <TSource> stream, Func <TSource, TKey> projection)
 {
     return(CSharpProxy.GroupBy(stream, projection));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Applies a key-generating function to each element of a ParStream and return a ParStream yielding unique keys and their number of occurrences in the original sequence.
 /// </summary>
 /// <param name="projection">A function that maps items from the input ParStream to keys.</param>
 /// <param name="stream">The input ParStream.</param>
 public static ParStream <Tuple <TKey, int> > CountBy <TSource, TKey>(this ParStream <TSource> stream, Func <TSource, TKey> projection)
 {
     return(CSharpProxy.CountBy(stream, projection));
 }
Exemplo n.º 5
0
 /// <summary>Returns true if the stream is empty, false otherwise.</summary>
 /// <param name="source">The input stream.</param>
 /// <returns>true if the input stream is empty, false otherwise.</returns>
 public static bool IsEmpty <T>(this ParStream <T> source)
 {
     return(CSharpProxy.IsEmpty(source));
 }
Exemplo n.º 6
0
 /// <summary>Returns a stream that skips N elements of the input parallel stream and then yields the remaining elements of the stream.</summary>
 /// <param name="n">The number of items to skip.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <TSource> Skip <TSource>(this ParStream <TSource> stream, int n)
 {
     return(ParStream.skip(n, stream));
 }
Exemplo n.º 7
0
 /// <summary>Applies a key-generating function to each element of a ParStream and return a ParStream yielding unique keys and the result of the threading an accumulator.</summary>
 /// <param name="projection">A function to transform items from the input ParStream to keys.</param>
 /// <param name="folder">A function that updates the state with each element from the ParStream.</param>
 /// <param name="state">A function that produces the initial state.</param>
 /// <param name="stream">The input ParStream.</param>
 /// <returns>The final result.</returns>
 public static ParStream <Tuple <TKey, TState> > AggregateBy <TSource, TKey, TState>(this ParStream <TSource> stream, Func <TSource, TKey> projection, Func <TState, TSource, TState> folder, Func <TState> state)
 {
     return(CSharpProxy.AggregateBy(stream, projection, folder, state));
 }
Exemplo n.º 8
0
 /// <summary>Returns the sum of the elements.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The sum of the elements.</returns>
 public static double Sum(this ParStream <double> stream)
 {
     return(CSharpProxy.Sum(stream));
 }
Exemplo n.º 9
0
 /// <summary>Returns the sum of the elements.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The sum of the elements.</returns>
 public static decimal Sum(this ParStream <decimal> stream)
 {
     return(CSharpProxy.Sum(stream));
 }
Exemplo n.º 10
0
 /// <summary>Returns the sum of the elements.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The sum of the elements.</returns>
 public static long Sum(this ParStream <long> stream)
 {
     return(CSharpProxy.Sum(stream));
 }
Exemplo n.º 11
0
 /// <summary>Returns the sum of the elements.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The sum of the elements.</returns>
 public static float Sum(this ParStream <float> stream)
 {
     return(CSharpProxy.Sum(stream));
 }
Exemplo n.º 12
0
 /// <summary>Applies a key-generating function to each element of the input parallel stream and yields a parallel stream ordered by keys in descending order.</summary>
 /// <param name="projection">A function to transform items of the input parallel stream into comparable keys.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <TSource> OrderByDescending <TSource, TKey>(this ParStream <TSource> stream, Func <TSource, TKey> projection) where TKey : IComparable <TKey>
 {
     return(CSharpProxy.OrderByDescending(stream, projection));
 }
Exemplo n.º 13
0
 /// <summary>Applies a function to each element of the parallel stream, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0)...) iN.</summary>
 /// <param name="state">A function that produces the initial state.</param>
 /// <param name="folder">A function that updates the state with each element from the parallel stream.</param>
 /// <param name="combiner">A function that combines partial states into a new state.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The final result.</returns>
 public static TAccumulate Aggregate <TSource, TAccumulate>(this ParStream <TSource> stream, Func <TAccumulate> state, Func <TAccumulate, TSource, TAccumulate> folder, Func <TAccumulate, TAccumulate, TAccumulate> combiner)
 {
     return(CSharpProxy.Aggregate(stream, state, folder, combiner));
 }
Exemplo n.º 14
0
 /// <summary>Returns the sum of the elements.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The sum of the elements.</returns>
 public static int Sum(this ParStream <int> stream)
 {
     return(CSharpProxy.Sum(stream));
 }
Exemplo n.º 15
0
 /// <summary>Tests if all elements of the parallel stream satisfy the given predicate.</summary>
 /// <param name="predicate">A function to test each source element for a condition.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>true if all of the elements satisfies the predicate. Otherwise, returns false.</returns>
 public static bool All <TSource>(this ParStream <TSource> stream, Func <TSource, bool> predicate)
 {
     return(CSharpProxy.All(stream, predicate));
 }
Exemplo n.º 16
0
 /// <summary>Returns the total number of elements of the parallel stream.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The total number of elements.</returns>
 public static int Count <TSource>(this ParStream <TSource> stream)
 {
     return(CSharpProxy.Count(stream));
 }
Exemplo n.º 17
0
 /// <summary>Returns the elements of the parallel stream up to a specified count.</summary>
 /// <param name="n">The number of items to take.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <TSource> Take <TSource>(this ParStream <TSource> stream, int n)
 {
     return(ParStream.take(n, stream));
 }
Exemplo n.º 18
0
 /// <summary>Creates an array from the given parallel stream.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result array.</returns>
 public static TSource[] ToArray <TSource>(this ParStream <TSource> stream)
 {
     return(ParStream.toArray(stream));
 }
Exemplo n.º 19
0
 /// <summary>Locates the minimum element of the parallel stream by given key.</summary>
 /// <param name="projection">A function to transform items of the input stream into comparable keys.</param>
 /// <param name="source">The input stream.</param>
 /// <returns>The maximum item.</returns>
 public static TSource MinBy <TSource, TKey>(this ParStream <TSource> source, Func <TSource, TKey> projection)
 {
     return(CSharpProxy.MinBy(source, projection));
 }
Exemplo n.º 20
0
 /// <summary>Creates an List from the given parallel stream.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result List.</returns>
 public static List <TSource> ToList <TSource>(this ParStream <TSource> stream)
 {
     return(ParStream.toResizeArray(stream));
 }
Exemplo n.º 21
0
 /// <summary>Wraps List as a parallel stream.</summary>
 /// <param name="source">The input array.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <T> AsParStream <T>(this List <T> source)
 {
     return(ParStream.ofResizeArray(source));
 }
Exemplo n.º 22
0
 /// <summary>Returns the first element for which the given function returns true. Raises InvalidOperationException if no such element exists.</summary>
 /// <param name="predicate">A function to test each source element for a condition.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The first element for which the predicate returns true.</returns>
 /// <exception cref="System.InvalidOperationException">Thrown if the predicate evaluates to false for all the elements of the parallel stream or if the parallel stream is empty.</exception>
 public static TSource First <TSource>(this ParStream <TSource> stream, Func <TSource, bool> predicate)
 {
     return(CSharpProxy.First(stream, predicate));
 }
Exemplo n.º 23
0
 /// <summary>Returns a parallel stream that is unordered.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream as unordered.</returns>
 public static ParStream <TSource> AsUnordered <TSource>(this ParStream <TSource> stream)
 {
     return(ParStream.unordered(stream));
 }
Exemplo n.º 24
0
 /// <summary>Wraps array as a parallel stream.</summary>
 /// <param name="source">The input array.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <T> AsParStream <T>(this T[] source)
 {
     return(ParStream.ofArray(source));
 }
Exemplo n.º 25
0
 /// <summary>Wraps IEnumerable as a parallel stream.</summary>
 /// <param name="source">The input seq.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <T> AsParStream <T>(this IEnumerable <T> source)
 {
     return(ParStream.ofSeq(source));
 }
Exemplo n.º 26
0
 /// <summary>Returns the first element in the stream, or the default value if the stream is empty.</summary>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The first element in the  parallel stream, or the default value if the parallel stream is empty.</returns>
 public static T FirstOrDefault <T>(this ParStream <T> stream)
 {
     return(CSharpProxy.FirstOrDefault(stream));
 }
Exemplo n.º 27
0
 /// <summary>Transforms each element of the input parallel stream to a new stream and flattens its elements.</summary>
 /// <param name="f">A function to transform items from the input parallel stream.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <TResult> SelectMany <TSource, TResult>(this ParStream <TSource> stream, Func <TSource, Stream <TResult> > f)
 {
     return(CSharpProxy.SelectMany(stream, f));
 }
Exemplo n.º 28
0
 /// <summary>Applies a key-generating function to each element of the input parallel stream and yields a parallel stream ordered using the given comparer for the keys.</summary>
 /// <param name="projection">A function to transform items of the input parallel stream into keys.</param>
 /// <param name="comparer">A comparer for the keys.</param>
 /// <param name="stream">The input parallel stream.</param>
 /// <returns>The result parallel stream.</returns>
 public static ParStream <TSource> OrderBy <TSource, TKey>(this ParStream <TSource> stream, Func <TSource, TKey> projection, IComparer <TKey> comparer) where TKey : IComparable <TKey>
 {
     return(CSharpProxy.OrderBy(stream, projection, comparer));
 }