Show / Hide Table of Contents

Class Comparable

Provides generic methods to work with comparable values.

Inheritance
Object
Comparable
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Comparable : object

Methods

| 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 = default(BoundType))

    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
Type Parameters
Name Description
T

Type of the values.

| Improve this Doc View Source

Max<T>(T, T)

Returns the larger of two values.

Declaration
public static T Max<T>(this T first, T second)

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

The first value.

T second

The second value.

Returns
Type Description
T

The larger of two values.

Type Parameters
Name Description
T

Type of the values.

| Improve this Doc View Source

Max<T>(T, T, Comparison<T>)

Returns the larger of two values.

Declaration
public static T Max<T>(T first, T second, Comparison<T> comparer)
Parameters
Type Name Description
T first

The first value.

T second

The second value.

DotNext.Comparison<T> comparer

Comparison function.

Returns
Type Description
T

The larger of two values.

Type Parameters
Name Description
T

Type of the values.

| Improve this Doc View Source

Max<T>(T, T, IComparer<T>)

Returns the larger of two values.

Declaration
public static T Max<T>(T first, T second, IComparer<T> comparer)
Parameters
Type Name Description
T first

The first value.

T second

The second value.

IComparer<T> comparer

Comparison function.

Returns
Type Description
T

The larger of two values.

Type Parameters
Name Description
T

Type of the values.

| Improve this Doc View Source

Min<T>(T, T)

Returns the smaller of two values.

Declaration
public static T Min<T>(this T first, T second)

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

The first value.

T second

The second value.

Returns
Type Description
T

The smaller of two values.

Type Parameters
Name Description
T

Type of the values.

| Improve this Doc View Source

Min<T>(T, T, Comparison<T>)

Returns the smaller of two values.

Declaration
public static T Min<T>(T first, T second, Comparison<T> comparer)
Parameters
Type Name Description
T first

The first value.

T second

The second value.

DotNext.Comparison<T> comparer

Comparison function.

Returns
Type Description
T

The smaller of two values.

Type Parameters
Name Description
T

Type of the values.

| Improve this Doc View Source

Min<T>(T, T, IComparer<T>)

Returns the smaller of two values.

Declaration
public static T Min<T>(T first, T second, IComparer<T> comparer)
Parameters
Type Name Description
T first

The first value.

T second

The second value.

IComparer<T> comparer

Comparison function.

Returns
Type Description
T

The smaller of two values.

Type Parameters
Name Description
T

Type of the values.

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