ElementComparer Class |
Namespace: Accord.Math.Comparers
The ElementComparer type exposes the following members.
Name | Description | |
---|---|---|
ElementComparer | Initializes a new instance of the ElementComparer class |
Name | Description | |
---|---|---|
Index |
Gets or sets the element index to compare.
(Inherited from ElementComparerT.) |
Name | Description | |
---|---|---|
Compare |
Compares two objects and returns a value indicating
whether one is less than, equal to, or greater than the other.
(Inherited from ElementComparerT.) | |
Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Equals(T, T) |
Determines whether two instances are equal.
(Inherited from ElementComparerT.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetHashCode(T) |
Returns a hash code for a given instance.
(Inherited from ElementComparerT.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(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.) | |
ToT | 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.) |
// 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 }, };