Table of Contents

Struct ExtendedComparable<TComparable>

Namespace
AlgorithmsSW
Assembly
AlgorithmsSW.dll

Wraps a value in a type that can also represent infinity. This gives us the ability to work more uniformly with floats and integers.

public readonly struct ExtendedComparable<TComparable> where TComparable : IComparisonOperators<TComparable, TComparable, bool>

Type Parameters

TComparable

The type of value to wrap.

Inherited Members
Extension Methods

Constructors

ExtendedComparable(TComparable)

Initializes a new instance of the ExtendedComparable<TComparable> struct that represents a finite value.

public ExtendedComparable(TComparable finiteValue)

Parameters

finiteValue TComparable

The finite value this ExtendedComparable<TComparable> represents.

Remarks

Use NegativeInfinity and PositiveInfinity for non-finite values.

Fields

NegativeInfinity

public static readonly ExtendedComparable<TComparable> NegativeInfinity

Field Value

ExtendedComparable<TComparable>

PositiveInfinity

public static readonly ExtendedComparable<TComparable> PositiveInfinity

Field Value

ExtendedComparable<TComparable>

Properties

FiniteValue

public TComparable FiniteValue { get; }

Property Value

TComparable

Methods

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(ExtendedComparable<TComparable>, ExtendedComparable<TComparable>)

public static bool operator ==(ExtendedComparable<TComparable> left, ExtendedComparable<TComparable> right)

Parameters

left ExtendedComparable<TComparable>
right ExtendedComparable<TComparable>

Returns

bool

explicit operator ExtendedComparable<TComparable>(TComparable)

public static explicit operator ExtendedComparable<TComparable>(TComparable value)

Parameters

value TComparable

Returns

ExtendedComparable<TComparable>

operator >(ExtendedComparable<TComparable>, ExtendedComparable<TComparable>)

public static bool operator >(ExtendedComparable<TComparable> left, ExtendedComparable<TComparable> right)

Parameters

left ExtendedComparable<TComparable>
right ExtendedComparable<TComparable>

Returns

bool

operator >=(ExtendedComparable<TComparable>, ExtendedComparable<TComparable>)

public static bool operator >=(ExtendedComparable<TComparable> left, ExtendedComparable<TComparable> right)

Parameters

left ExtendedComparable<TComparable>
right ExtendedComparable<TComparable>

Returns

bool

operator !=(ExtendedComparable<TComparable>, ExtendedComparable<TComparable>)

public static bool operator !=(ExtendedComparable<TComparable> left, ExtendedComparable<TComparable> right)

Parameters

left ExtendedComparable<TComparable>
right ExtendedComparable<TComparable>

Returns

bool

operator <(ExtendedComparable<TComparable>, ExtendedComparable<TComparable>)

public static bool operator <(ExtendedComparable<TComparable> left, ExtendedComparable<TComparable> right)

Parameters

left ExtendedComparable<TComparable>
right ExtendedComparable<TComparable>

Returns

bool

operator <=(ExtendedComparable<TComparable>, ExtendedComparable<TComparable>)

public static bool operator <=(ExtendedComparable<TComparable> left, ExtendedComparable<TComparable> right)

Parameters

left ExtendedComparable<TComparable>
right ExtendedComparable<TComparable>

Returns

bool