Generated by DocFX

Class GeneralComparer

General comparer which supports multiple directions and comparison of absolute values.

Inheritance
System.Object
GeneralComparer
Implements
IComparer<System.Int32>
Namespace: ISynergy.Framework.Mathematics.Comparers
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public class GeneralComparer : IComparer<double>
Examples
// Assume we have values to sort
double[] values = { 0, -5, 3, 1, 8 };

// We can create an ad-hoc sorting rule considering only absolute values
Array.Sort(values, new GeneralComparer(ComparerDirection.Ascending, Math.Abs));

// Result will be { 0, 1, 3, 5, 8 }.

Constructors

View Source

GeneralComparer(ComparerDirection)

Constructs a new General Comparer.

Declaration
public GeneralComparer(ComparerDirection direction)
Parameters
Type Name Description
ComparerDirection direction

The direction to compare.

View Source

GeneralComparer(ComparerDirection, Func<Double, Double>)

Constructs a new General Comparer.

Declaration
public GeneralComparer(ComparerDirection direction, Func<double, double> map)
Parameters
Type Name Description
ComparerDirection direction

The direction to compare.

Func<System.Double, System.Double> map

The mapping function which will be applied to each vector element prior to any comparisons.

View Source

GeneralComparer(ComparerDirection, Boolean)

Constructs a new General Comparer.

Declaration
public GeneralComparer(ComparerDirection direction, bool useAbsoluteValues)
Parameters
Type Name Description
ComparerDirection direction

The direction to compare.

System.Boolean useAbsoluteValues

True to compare absolute values, false otherwise. Default is false.

Properties

View Source

Direction

Gets or sets the sorting direction used by this comparer.

Declaration
public ComparerDirection Direction { get; set; }
Property Value
Type Description
ComparerDirection

Methods

View Source

Compare(Double, Double)

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

Declaration
public int Compare(double x, double y)
Parameters
Type Name Description
System.Double x

The first object to compare.

System.Double y

The second object to compare.

Returns
Type Description
System.Int32
View Source

Compare(Int32, Int32)

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

Declaration
public int Compare(int x, int y)
Parameters
Type Name Description
System.Int32 x

The first object to compare.

System.Int32 y

The second object to compare.

Returns
Type Description
System.Int32

Implements

IComparer<>

Extension Methods

Matrix.Replace<T>(T, Object, Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
EntityBaseExtensions.HasProperty(Object, String)
ArrayExtensions.Concatenate<T>(T, T[])
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>, Func<TSource, Boolean>)
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>)
ObjectExtensions.Clone<T>(T)
ObjectExtensions.To<T>(Object)
ObjectExtensions.To(Object, Type)
ObjectExtensions.HasMethod(Object, String)
ObjectExtensions.AddressOf<T>(T)
ReflectionExtensions.GetIdentityValue<T>(T)
ReflectionExtensions.GetIdentityValue<T, TResult>(T)
ReflectionExtensions.GetIdentityProperty<T>(T)
ReflectionExtensions.HasIdentityProperty<T>(T)
ReflectionExtensions.GetPropertyValue<T, TResult>(T, String, TResult)
ReflectionExtensions.GetPropertyInfo<T, TValue>(T, Expression<Func<T, TValue>>)
ReflectionExtensions.GetTitleValue<T>(T)
ReflectionExtensions.HasParentIdentityProperty<T>(T)
ReflectionExtensions.GetParentIdentityProperty<T>(T)
ReflectionExtensions.IsFreeApplication<T>(T)

See Also

ElementComparer<T>
ArrayComparer<T>
GeneralComparer
CustomComparer<T>