ParallelHelperSortTKeyFrom, TKeyTo, TValueFrom, TValueTo(CastArrayTKeyFrom, TKeyTo, CastArrayTValueFrom, TValueTo, IComparerTKeyTo) Method
Sorts the elements in a pair of
CastArrayTFrom, TTo instances synchronously (one contains the keys, the other contains the corresponding values), potentially using multiple threads.
Namespace: KGySoft.ThreadingAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
public static void Sort<TKeyFrom, TKeyTo, TValueFrom, TValueTo>(
CastArray<TKeyFrom, TKeyTo> keys,
CastArray<TValueFrom, TValueTo> values,
IComparer<TKeyTo>? comparer = null
)
where TKeyFrom : struct, new()
where TKeyTo : struct, new()
where TValueFrom : struct, new()
where TValueTo : struct, new()
Public Shared Sub Sort(Of TKeyFrom As {Structure, New}, TKeyTo As {Structure, New}, TValueFrom As {Structure, New}, TValueTo As {Structure, New}) (
keys As CastArray(Of TKeyFrom, TKeyTo),
values As CastArray(Of TValueFrom, TValueTo),
Optional comparer As IComparer(Of TKeyTo) = Nothing
)
public:
generic<typename TKeyFrom, typename TKeyTo, typename TValueFrom, typename TValueTo>
where TKeyFrom : value class, gcnew()
where TKeyTo : value class, gcnew()
where TValueFrom : value class, gcnew()
where TValueTo : value class, gcnew()
static void Sort(
CastArray<TKeyFrom, TKeyTo> keys,
CastArray<TValueFrom, TValueTo> values,
IComparer<TKeyTo>^ comparer = nullptr
)
static member Sort :
keys : CastArray<'TKeyFrom, 'TKeyTo> *
values : CastArray<'TValueFrom, 'TValueTo> *
?comparer : IComparer<'TKeyTo>
(* Defaults:
let _comparer = defaultArg comparer null
*)
-> unit when 'TKeyFrom : struct, new() when 'TKeyTo : struct, new() when 'TValueFrom : struct, new() when 'TValueTo : struct, new()
- keys CastArrayTKeyFrom, TKeyTo
- The CastArrayTFrom, TTo that contains the keys to sort.
- values CastArrayTValueFrom, TValueTo
- The CastArrayTFrom, TTo that contains the values that correspond to the keys in the keys collection.
If the IsNull property of values is , then only the keys are sorted.
- comparer IComparerTKeyTo (Optional)
- The IComparerT implementation to use when comparing elements, or to use a default comparer. This parameter is optional.
Default value: .
- TKeyFrom
- The actual element type of the underlying array in keys.
- TKeyTo
- The reinterpreted element type of the CastArrayTFrom, TTo instance in keys.
- TValueFrom
- The actual element type of the underlying array in values.
- TValueTo
- The reinterpreted element type of the CastArrayTFrom, TTo instance in values.
This method adjusts the degree of parallelization automatically, blocks the caller, and does not support cancellation.
Use the overloads with a
ParallelConfig parameter to adjust parallelization and to set up cancellation;
or the
BeginSort/
SortAsync
(in .NET Framework 4.0 and above) methods to perform the sorting asynchronously.