|
SortPartitionTKey, TValue Method (TKey, TValue, Int32, Int32, FuncTKey, TKey, Int32, Boolean)
|
Reorders the elements in the range [left, right) in such a way that all elements for which
the function compare returns true precede the elements for which compare
returns false. Relative order of the elements is not preserved. This function should be equivalent
to C++'s std::partition.
Namespace:
Accord
Assembly:
Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax public static int Partition<TKey, TValue>(
this TKey[] keys,
TValue[] items,
int first,
int last,
Func<TKey, TKey, int> compare,
bool asc = true
)
<ExtensionAttribute>
Public Shared Function Partition(Of TKey, TValue) (
keys As TKey(),
items As TValue(),
first As Integer,
last As Integer,
compare As Func(Of TKey, TKey, Integer),
Optional asc As Boolean = true
) As Integer
Request Example
View SourceParameters
- keys
- Type: TKey
The list to be reordered. - items
- Type: TValue
An array of keys associated with each element in the list. - first
- Type: SystemInt32
The beginning of the range to be reordered. - last
- Type: SystemInt32
The end of the range to be reordered. - compare
- Type: SystemFuncTKey, TKey, Int32
Function to use in the comparison. - asc (Optional)
- Type: SystemBoolean
Whether to sort in ascending or descending order.
Type Parameters
- TKey
- TValue
Return Value
Type:
Int32The index of the new pivot.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
See Also