Click or drag to resize
Accord.NET (logo)

ElementComparer Class

Element-at-position comparer.
Inheritance Hierarchy
SystemObject
  Accord.Math.ComparersElementComparerDouble
    Accord.Math.ComparersElementComparer

Namespace:  Accord.Math.Comparers
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public class ElementComparer : ElementComparer<double>
Request Example View Source

The ElementComparer type exposes the following members.

Constructors
  NameDescription
Public methodElementComparer
Initializes a new instance of the ElementComparer class
Top
Properties
Methods
  NameDescription
Public methodCompare
Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
(Inherited from ElementComparerT.)
Public methodEquals(Object)
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodEquals(T, T)
Determines whether two instances are equal.
(Inherited from ElementComparerT.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetHashCode(T)
Returns a hash code for a given instance.
(Inherited from ElementComparerT.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks
This class compares arrays by checking the value of a particular element at a given array index.
Examples
// We sort the arrays according to the 
// elements at their second column.

double[][] values =
{   //                 v
    new double[] {  0, 3, 0 },
    new double[] {  0, 4, 1 },
    new double[] { -1, 1, 1 },
    new double[] { -1, 5, 4 },
    new double[] { -2, 2, 6 },
};

// Sort the array considering only the second column
Array.Sort(values, new ElementComparer() { Index = 1 });

// The result will be
double[][] result =
{
    new double[] { -1, 1, 1 },
    new double[] { -2, 2, 6 },
    new double[] {  0, 3, 0 },
    new double[] {  0, 4, 1 },
    new double[] { -1, 5, 4 },
};
See Also