Table of Contents

Class IComparableExtensions

Namespace
Garyon.Extensions
Assembly
Garyon.dll

Provides extension methods for the IComparable and IComparable<T> interfaces.

public static class IComparableExtensions
Inheritance
IComparableExtensions
Inherited Members

Methods

AssignExtremum<T>(ref T, T, Extremum)

Assigns a variable storing a extremum value to other, if found to be suitable as the new extremum.

public static void AssignExtremum<T>(this ref T extremum, T other, Extremum targetExtremum) where T : struct, IComparable<T>

Parameters

extremum T

A reference to the variable storing the extremum. It may be overwritten if the comparison of other against extremum matches that of targetExtremum.

other T

The other value to overwrite extremum with, if deemed as the new extremum.

targetExtremum Extremum

The target extremum to match.

Type Parameters

T

The type of the values being compared.

AssignMax<T>(ref T, T)

Assigns a variable storing a maximum value to other, if found to be greater than the current maximum.

public static void AssignMax<T>(this ref T max, T other) where T : struct, IComparable<T>

Parameters

max T

A reference to the variable storing the maximum. It may be overwritten if other is greater than the current maximum.

other T

The other value to overwrite max with, if found to be greater than it.

Type Parameters

T

The type of the values being compared.

AssignMin<T>(ref T, T)

Assigns a variable storing a minimum value to other, if found to be less than the current minimum.

public static void AssignMin<T>(this ref T min, T other) where T : struct, IComparable<T>

Parameters

min T

A reference to the variable storing the minimum. It may be overwritten if other is less than the current minimum.

other T

The other value to overwrite min with, if found to be less than it.

Type Parameters

T

The type of the values being compared.

EqualTo(IComparable, object)

Determines whether value is equal to other.

public static bool EqualTo(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

bool

true if value is equal to other, otherwise false.

EqualTo<T>(IComparable<T>, T)

Determines whether value is equal to other.

public static bool EqualTo<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

bool

true if value is equal to other, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

GetComparisonResult(IComparable, object)

Determines the result of the comparison of value with other.

public static ComparisonResult GetComparisonResult(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

ComparisonResult

A ComparisonResult representing the result of the comparison of value with other.

GetComparisonResult<T>(IComparable<T>, T)

Determines the result of the comparison of value with other.

public static ComparisonResult GetComparisonResult<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

ComparisonResult

A ComparisonResult representing the result of the comparison of value with other.

Type Parameters

T

The type of the value that value can be compared with.

GreaterThan(IComparable, object)

Determines whether value is greater than other.

public static bool GreaterThan(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

bool

true if value is greater than other, otherwise false.

GreaterThanOrEqual(IComparable, object)

Determines whether value is greater than or equal to other.

public static bool GreaterThanOrEqual(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

bool

true if value is greater than or equal to other, otherwise false.

GreaterThanOrEqual<T>(IComparable<T>, T)

Determines whether value is greater than or equal to other.

public static bool GreaterThanOrEqual<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

bool

true if value is greater than or equal to other, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

GreaterThan<T>(IComparable<T>, T)

Determines whether value is greater than other.

public static bool GreaterThan<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

bool

true if value is greater than other, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

LessThan(IComparable, object)

Determines whether value is less than other.

public static bool LessThan(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

bool

true if value is less than other, otherwise false.

LessThanOrEqual(IComparable, object)

Determines whether value is less than or equal to other.

public static bool LessThanOrEqual(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

bool

true if value is less than or equal to other, otherwise false.

LessThanOrEqual<T>(IComparable<T>, T)

Determines whether value is less than or equal to other.

public static bool LessThanOrEqual<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

bool

true if value is less than or equal to other, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

LessThan<T>(IComparable<T>, T)

Determines whether value is less than other.

public static bool LessThan<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

bool

true if value is less than other, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

MatchesComparisonResult(IComparable, object, ComparisonResult)

Determines whether the comparison of value and other matches the expected result.

public static bool MatchesComparisonResult(this IComparable value, object other, ComparisonResult result)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

result ComparisonResult

The expected comparison result.

Returns

bool

true if the comparison of value with other matches the expected result, otherwise false.

MatchesComparisonResult<T>(IComparable<T>, T, ComparisonResult)

Determines whether the comparison of value and other matches the expected result.

public static bool MatchesComparisonResult<T>(this IComparable<T> value, T other, ComparisonResult result)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

result ComparisonResult

The expected comparison result.

Returns

bool

true if the comparison of value with other matches the expected result, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

NotEqualTo(IComparable, object)

Determines whether value is not equal to other.

public static bool NotEqualTo(this IComparable value, object other)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

Returns

bool

true if value is not equal to other, otherwise false.

NotEqualTo<T>(IComparable<T>, T)

Determines whether value is not equal to other.

public static bool NotEqualTo<T>(this IComparable<T> value, T other)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

Returns

bool

true if value is not equal to other, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.

SatisfiesComparison(IComparable, object, ComparisonKinds)

Determines whether the comparison of value and other satisfies the given comparison.

public static bool SatisfiesComparison(this IComparable value, object other, ComparisonKinds kinds)

Parameters

value IComparable

The provided value to compare.

other object

The other value to compare.

kinds ComparisonKinds

The comparison kinds.

Returns

bool

true if the comparison of value with other is satisfied, otherwise false.

SatisfiesComparison<T>(IComparable<T>, T, ComparisonKinds)

Determines whether the comparison of value and other satisfies the given comparison.

public static bool SatisfiesComparison<T>(this IComparable<T> value, T other, ComparisonKinds kinds)

Parameters

value IComparable<T>

The provided value to compare.

other T

The other value to compare.

kinds ComparisonKinds

The comparison kinds.

Returns

bool

true if the comparison of value with other is satisfied, otherwise false.

Type Parameters

T

The type of the value that value can be compared with.