Class StableComparer<T>
Stable comparer for stable sorting algorithm.
Inheritance
IComparer<KeyValuePair<System.Int32, T>>
StableComparer<T>
Namespace: Mars.Numerics.Comparers
Assembly: Mars.Numerics.dll
Syntax
public class StableComparer<T> : IComparer<KeyValuePair<int, T>>
Type Parameters
Name | Description |
---|---|
T | The type of objects to compare. |
Remarks
This class helps sort the elements of an array without swapping
elements which are already in order. This comprises a
stable
sorting algorithm.
Constructors
StableComparer(Comparison<T>)
Constructs a new instance of the StableComparer<T> class.
Declaration
public StableComparer(Comparison<T> comparison)
Parameters
Type | Name | Description |
---|---|---|
Comparison<T> | comparison | The comparison function. |
Methods
Compare(KeyValuePair<Int32, T>, KeyValuePair<Int32, T>)
Compares two objects and returns a value indicating
whether one is less than, equal to, or greater than
the other.
Declaration
public int Compare(KeyValuePair<int, T> x, KeyValuePair<int, T> y)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<System.Int32, T> | x | The first object to compare. |
KeyValuePair<System.Int32, T> | y | The second object to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A signed integer that indicates the relative values of x and y. |