SystemEX  Lacking
Additional generic collection types missing in .net
SystemEx.IComparableEx< T > Interface Template Reference

Provides an extended and strongly typed comparison contract for SystemEx. More...

Inheritance diagram for SystemEx.IComparableEx< T >:

Public Member Functions

CompareResult CompareTo (T a)
 Compares this instance with the specified value and returns a CompareResult describing the relationship between them.

Detailed Description

Provides an extended and strongly typed comparison contract for SystemEx.

Unlike System.IComparable<T>, which returns an integer (-1, 0, +1), this interface uses the explicit CompareResult enumeration. This makes comparison outcomes easier to interpret and avoids ambiguity, especially in low‑level or domain‑specific types.

Compatibility with IComparable<T>:
Since CompareResult is backed by an integer, any type can implement both interfaces simultaneously. The standard CompareTo method can simply cast the extended result:

public sealed class Foo : IComparableEx&lt;Foo&gt;, IComparable&lt;Foo&gt;
{
public CompareResult CompareTo(Foo other)
{
// Custom comparison logic...
return CompareResult.Equal;
}
int IComparable&lt;Foo&gt;.CompareTo(Foo other)
{
// Cast the extended comparison result to an int.
return (int)CompareTo(other);
}
}
CompareResult CompareTo(T a)
Compares this instance with the specified value and returns a CompareResult describing the relationsh...
CompareResult
Specifies the result of a comparison between two values.
Definition Algorithm.cs:26

This interface is intentionally generic and can be implemented by any type: numeric primitives, geometric structures, colors, states, or any other domain‑specific objects requiring deterministic comparison semantics.

Template Parameters
TThe type that this instance can be compared against.

Member Function Documentation

◆ CompareTo()

CompareResult SystemEx.IComparableEx< T >.CompareTo ( T a)

Compares this instance with the specified value and returns a CompareResult describing the relationship between them.

Implementations may define their own comparison rules, such as: magnitude-based, lexicographical, structural, bitwise, or any domain-specific logic required by the type.

The comparison must be deterministic and should not depend on external state, floating‑point environment, or platform-specific behavior. This makes the interface suitable for low-level systems, serialization, math primitives, and engine-independent utilities.

Parameters
aThe value to compare with this instance.
Returns
A CompareResult indicating whether this instance is less than, equal to, or greater than a .

The documentation for this interface was generated from the following file:
  • IComparableEx.cs