Show / Hide Table of Contents

Class Comparison

Provides generic methods to work with comparable values.

Inheritance
Object
Comparison
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Comparison

Methods

| Improve this Doc View Source

AsValueFunc<T>(Comparison<T>, Boolean)

Converts comparison method into ValueFunc<T1, T2, TResult>.

Declaration
public static ValueFunc<T, T, int> AsValueFunc<T>(this Comparison<T> comparison, bool wrap = false)
Parameters
Type Name Description
Comparison<T> comparison

The delegate representing comparison method.

Boolean wrap

true to wrap comparison into this delegate; false to extract method pointer without holding reference to the passed delegate.

Returns
Type Description
ValueFunc<T, T, Int32>

The value delegate represeting comparison method.

Type Parameters
Name Description
T

The type of the object to compare.

| Improve this Doc View Source

Between<T>(T, T, T, BoundType)

Checks whether specified value is in range.

Declaration
public static bool Between<T>(this T value, T left, T right, BoundType boundType = BoundType.Open)

    where T : IComparable<T>
Parameters
Type Name Description
T value

Value to check.

T left

Range left bound.

T right

Range right bound.

BoundType boundType

Range endpoints bound type.

Returns
Type Description
Boolean

true, if value is in its bounds.

Type Parameters
Name Description
T

Type of value to check.

| Improve this Doc View Source

Clamp<T>(T, T, T)

Restricts a value in specific range.

Declaration
public static T Clamp<T>(this T value, T min, T max)

    where T : IComparable<T>
Parameters
Type Name Description
T value

Value to be restricted.

T min

Minimal range value.

T max

Maximum range value.

Returns
Type Description
T

value if min ≤ value ≤ max; or min if value < min; or max if max < value.

Type Parameters
Name Description
T

Type of the values.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX