Method SortedMerge
View SourceSortedMerge<TSource>(IAsyncEnumerable<TSource>, params IAsyncEnumerable<TSource>[])
Merges two or more sequences that are in a common order (either ascending or descending) into a single sequence that preserves that order.
Declaration
public static IAsyncEnumerable<TSource> SortedMerge<TSource>(this IAsyncEnumerable<TSource> source, params IAsyncEnumerable<TSource>[] otherSequences)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The primary sequence with which to merge |
IAsyncEnumerable<TSource>[] | otherSequences | A variable argument array of zero or more other sequences to merge with |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A merged, order-preserving sequence containing all of the elements of the original sequences |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the sequence |
Remarks
Using SortedMerge on sequences that are not ordered or are not in the same order produces
undefined results.
This method uses deferred execution and streams its results.
Here is an example of a merge, as well as the produced result:
var s1 = new[] { 3, 7, 11 };
var s2 = new[] { 2, 4, 20 };
var s3 = new[] { 17, 19, 25 };
var merged = s1.SortedMerge( OrderByDirection.Ascending, s2, s3 );
var result = merged.ToArray();
// result will be:
// { 2, 3, 4, 7, 11, 17, 19, 20, 25 }
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
SortedMerge<TSource>(IAsyncEnumerable<TSource>, IComparer<TSource>?, params IAsyncEnumerable<TSource>[])
Merges two or more sequences that are in a common order (either ascending or descending) into a single sequence that preserves that order.
Declaration
public static IAsyncEnumerable<TSource> SortedMerge<TSource>(this IAsyncEnumerable<TSource> source, IComparer<TSource>? comparer, params IAsyncEnumerable<TSource>[] otherSequences)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The primary sequence with which to merge |
IComparer<TSource> | comparer | The comparer used to evaluate the relative order between elements |
IAsyncEnumerable<TSource>[] | otherSequences | A variable argument array of zero or more other sequences to merge with |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A merged, order-preserving sequence containing all of the elements of the original sequences |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the sequence |
Remarks
Using SortedMerge on sequences that are not ordered or are not in the same order produces
undefined results.
This method uses deferred execution and streams its results.
Here is an example of a merge, as well as the produced result:
var s1 = new[] { 3, 7, 11 };
var s2 = new[] { 2, 4, 20 };
var s3 = new[] { 17, 19, 25 };
var merged = s1.SortedMerge( OrderByDirection.Ascending, s2, s3 );
var result = merged.ToArray();
// result will be:
// { 2, 3, 4, 7, 11, 17, 19, 20, 25 }
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
SortedMerge<TSource>(IAsyncEnumerable<TSource>, OrderByDirection, params IAsyncEnumerable<TSource>[])
Merges two or more sequences that are in a common order (either ascending or descending) into a single sequence that preserves that order.
Declaration
public static IAsyncEnumerable<TSource> SortedMerge<TSource>(this IAsyncEnumerable<TSource> source, OrderByDirection direction, params IAsyncEnumerable<TSource>[] otherSequences)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The primary sequence with which to merge |
OrderByDirection | direction | The ordering that all sequences must already exhibit |
IAsyncEnumerable<TSource>[] | otherSequences | A variable argument array of zero or more other sequences to merge with |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A merged, order-preserving sequence containing all of the elements of the original sequences |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the sequence |
Remarks
Using SortedMerge on sequences that are not ordered or are not in the same order produces
undefined results.
This method uses deferred execution and streams its results.
Here is an example of a merge, as well as the produced result:
var s1 = new[] { 3, 7, 11 };
var s2 = new[] { 2, 4, 20 };
var s3 = new[] { 17, 19, 25 };
var merged = s1.SortedMerge( OrderByDirection.Ascending, s2, s3 );
var result = merged.ToArray();
// result will be:
// { 2, 3, 4, 7, 11, 17, 19, 20, 25 }
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|
SortedMerge<TSource>(IAsyncEnumerable<TSource>, OrderByDirection, IComparer<TSource>?, params IAsyncEnumerable<TSource>[])
Merges two or more sequences that are in a common order (either ascending or descending) into a single sequence that preserves that order.
Declaration
public static IAsyncEnumerable<TSource> SortedMerge<TSource>(this IAsyncEnumerable<TSource> source, OrderByDirection direction, IComparer<TSource>? comparer, params IAsyncEnumerable<TSource>[] otherSequences)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The primary sequence with which to merge |
OrderByDirection | direction | The ordering that all sequences must already exhibit |
IComparer<TSource> | comparer | The comparer used to evaluate the relative order between elements |
IAsyncEnumerable<TSource>[] | otherSequences | A variable argument array of zero or more other sequences to merge with |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A merged, order-preserving sequence containing all of the elements of the original sequences |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in the sequence |
Remarks
Using SortedMerge on sequences that are not ordered or are not in the same order produces
undefined results.
This method uses deferred execution and streams its results.
Here is an example of a merge, as well as the produced result:
var s1 = new[] { 3, 7, 11 };
var s2 = new[] { 2, 4, 20 };
var s3 = new[] { 17, 19, 25 };
var merged = s1.SortedMerge( OrderByDirection.Ascending, s2, s3 );
var result = merged.ToArray();
// result will be:
// { 2, 3, 4, 7, 11, 17, 19, 20, 25 }
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|