Gorgon
Show / Hide Table of Contents

Struct GorgonRange

A type that represents a range between two int values.

Implements
IGorgonEquatableByRef<GorgonRange>
IEquatable<GorgonRange>
IComparable<GorgonRange>
Inherited Members
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Core
Assembly: Gorgon.Core.dll
Syntax
public readonly struct GorgonRange : IGorgonEquatableByRef<GorgonRange>, IEquatable<GorgonRange>, IComparable<GorgonRange>
Remarks

This a means to determine the range between a minimum int value and a maximum int value. Use this object to determine if a value falls within a specific range of values.

Constructors

| Edit this page View Source

GorgonRange(GorgonRange)

Initializes a new instance of the GorgonRange struct.

Declaration
public GorgonRange(GorgonRange minMax)
Parameters
Type Name Description
GorgonRange minMax

The min max value to copy.

| Edit this page View Source

GorgonRange(int, int)

Initializes a new instance of the GorgonRange struct.

Declaration
public GorgonRange(int min, int max)
Parameters
Type Name Description
int min

The minimum value.

int max

The maximum value.

Fields

| Edit this page View Source

Empty

An empty range value.

Declaration
public static readonly GorgonRange Empty
Field Value
Type Description
GorgonRange
| Edit this page View Source

Maximum

The maximum value in the range.

Declaration
public readonly int Maximum
Field Value
Type Description
int
| Edit this page View Source

Minimum

The minimum value in the range.

Declaration
public readonly int Minimum
Field Value
Type Description
int

Properties

| Edit this page View Source

IsEmpty

Property to return whether the range is empty or not.

Declaration
[JsonIgnore]
public bool IsEmpty { get; }
Property Value
Type Description
bool
| Edit this page View Source

Range

Property to return the range between the two values.

Declaration
[JsonIgnore]
public int Range { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

Add(GorgonRange, GorgonRange)

Function to add two GorgonRange values together.

Declaration
public static GorgonRange Add(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left GorgonRange value to add

GorgonRange right

The right GorgonRange value to add.

Returns
Type Description
GorgonRange

A new GorgonRange representing the total of both ranges.

| Edit this page View Source

Add(in GorgonRange, in GorgonRange, out GorgonRange)

Function to add two GorgonRange values together.

Declaration
public static void Add(in GorgonRange left, in GorgonRange right, out GorgonRange result)
Parameters
Type Name Description
GorgonRange left

The left GorgonRange value to add

GorgonRange right

The right GorgonRange value to add.

GorgonRange result

A new GorgonRange representing the total of both ranges.

| Edit this page View Source

CompareTo(GorgonRange)

Compares the current object with another object of the same type.

Declaration
public int CompareTo(GorgonRange other)
Parameters
Type Name Description
GorgonRange other

An object to compare with this object.

Returns
Type Description
int

A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the other parameter.Zero This object is equal to other. Greater than zero This object is greater than other.

| Edit this page View Source

Contains(int)

Function to return whether the int value falls within this GorgonRange.

Declaration
public bool Contains(int value)
Parameters
Type Name Description
int value

Value to test.

Returns
Type Description
bool

true if the value falls into the range, false if not.

| Edit this page View Source

Divide(GorgonRange, int)

Function to divide a GorgonRange by a int value.

Declaration
public static GorgonRange Divide(GorgonRange range, int scalar)
Parameters
Type Name Description
GorgonRange range

The GorgonRange range value to divide.

int scalar

The int scalar value to divide by.

Returns
Type Description
GorgonRange

A new GorgonRange representing the product of the range and the scalar.

Exceptions
Type Condition
DivideByZeroException

Thrown if the scalar value is zero.

| Edit this page View Source

Divide(in GorgonRange, int, out GorgonRange)

Function to divide a GorgonRange by a int value.

Declaration
public static void Divide(in GorgonRange range, int scalar, out GorgonRange result)
Parameters
Type Name Description
GorgonRange range

The GorgonRange range value to divide.

int scalar

The int scalar value to divide by.

GorgonRange result

A new GorgonRange representing the product of the range and the scalar.

Exceptions
Type Condition
DivideByZeroException

Thrown if the scalar value is zero.

| Edit this page View Source

Equals(GorgonRange)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(GorgonRange other)
Parameters
Type Name Description
GorgonRange other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

Equals(in GorgonRange)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(in GorgonRange other)
Parameters
Type Name Description
GorgonRange other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

Equals(object)

Indicates whether this instance and a specified object are equal.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

Another object to compare to.

Returns
Type Description
bool

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

Overrides
ValueType.Equals(object)
| Edit this page View Source

Expand(GorgonRange, int)

Function to expand a GorgonRange by a specific amount.

Declaration
public static GorgonRange Expand(GorgonRange range, int amount)
Parameters
Type Name Description
GorgonRange range

A GorgonRange to expand.

int amount

The amount to expand the GorgonRange by.

Returns
Type Description
GorgonRange

A new GorgonRange value, increased in size by amount.

| Edit this page View Source

Expand(in GorgonRange, int, out GorgonRange)

Function to expand a GorgonRange by a specific amount.

Declaration
public static void Expand(in GorgonRange range, int amount, out GorgonRange result)
Parameters
Type Name Description
GorgonRange range

A GorgonRange to expand.

int amount

The amount to expand the GorgonRange by.

GorgonRange result

A new GorgonRange value, increased in size by amount.

| Edit this page View Source

GetHashCode()

Returns the hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

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

Overrides
ValueType.GetHashCode()
| Edit this page View Source

Multiply(GorgonRange, GorgonRange)

Function to multiply two GorgonRange ranges together.

Declaration
public static GorgonRange Multiply(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left GorgonRange value to multiply.

GorgonRange right

The right GorgonRange value to multiply.

Returns
Type Description
GorgonRange

A new GorgonRange value representing the product of both ranges.

| Edit this page View Source

Multiply(GorgonRange, int)

Function to multiply a GorgonRange by a scalar int value.

Declaration
public static GorgonRange Multiply(GorgonRange range, int scalar)
Parameters
Type Name Description
GorgonRange range

The range to multiply by.

int scalar

The int scalar value to multiply.

Returns
Type Description
GorgonRange

A new GorgonRange representing the product of the range and the scalar.

| Edit this page View Source

Multiply(in GorgonRange, in GorgonRange, out GorgonRange)

Function to multiply two GorgonRange ranges together.

Declaration
public static void Multiply(in GorgonRange left, in GorgonRange right, out GorgonRange result)
Parameters
Type Name Description
GorgonRange left

The left GorgonRange value to multiply.

GorgonRange right

The right GorgonRange value to multiply.

GorgonRange result

A new GorgonRange value representing the product of both ranges.

| Edit this page View Source

Multiply(in GorgonRange, int, out GorgonRange)

Function to multiply a GorgonRange by a scalar int value.

Declaration
public static void Multiply(in GorgonRange range, int scalar, out GorgonRange result)
Parameters
Type Name Description
GorgonRange range

The range to multiply by.

int scalar

The int scalar value to multiply.

GorgonRange result

A new GorgonRange representing the product of the range and the scalar.

| Edit this page View Source

Shrink(GorgonRange, int)

Function to shrink a GorgonRange by a specific amount.

Declaration
public static GorgonRange Shrink(GorgonRange range, int amount)
Parameters
Type Name Description
GorgonRange range

A GorgonRange to shrink.

int amount

The amount to shrink the GorgonRange by.

Returns
Type Description
GorgonRange

A new GorgonRange value, decreased in size by amount.

| Edit this page View Source

Shrink(in GorgonRange, int, out GorgonRange)

Function to shrink a GorgonRange by a specific amount.

Declaration
public static void Shrink(in GorgonRange range, int amount, out GorgonRange result)
Parameters
Type Name Description
GorgonRange range

A GorgonRange to shrink.

int amount

The amount to shrink the GorgonRange by.

GorgonRange result

A new GorgonRange value, decreased in size by amount.

| Edit this page View Source

Subtract(GorgonRange, GorgonRange)

Function to subtract two GorgonRange ranges from each other.

Declaration
public static GorgonRange Subtract(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left GorgonRange value to subtract.

GorgonRange right

The right GorgonRange value to subtract.

Returns
Type Description
GorgonRange

A new GorgonRange value representing the difference of both ranges.

| Edit this page View Source

Subtract(in GorgonRange, in GorgonRange, out GorgonRange)

Function to subtract two GorgonRange ranges from each other.

Declaration
public static void Subtract(in GorgonRange left, in GorgonRange right, out GorgonRange result)
Parameters
Type Name Description
GorgonRange left

The left GorgonRange value to subtract.

GorgonRange right

The right GorgonRange value to subtract.

GorgonRange result

A new GorgonRange value representing the difference of both ranges.

| Edit this page View Source

ToGorgonRangeD(GorgonRange)

Function to perform an explicit conversion from GorgonRange to GorgonRangeD.

Declaration
public static GorgonRangeD ToGorgonRangeD(GorgonRange range)
Parameters
Type Name Description
GorgonRange range

The range.

Returns
Type Description
GorgonRangeD

The result of the conversion.

| Edit this page View Source

ToGorgonRangeF(GorgonRange)

Function to perform an explicit conversion from GorgonRange to GorgonRangeF.

Declaration
public static GorgonRangeF ToGorgonRangeF(GorgonRange range)
Parameters
Type Name Description
GorgonRange range

The range.

Returns
Type Description
GorgonRangeF

The result of the conversion.

| Edit this page View Source

ToGorgonRangeM(GorgonRange)

Function to perform an explicit conversion from GorgonRange to GorgonRangeM.

Declaration
public static GorgonRangeM ToGorgonRangeM(GorgonRange range)
Parameters
Type Name Description
GorgonRange range

The range.

Returns
Type Description
GorgonRangeM

The result of the conversion.

| Edit this page View Source

ToString()

Returns the fully qualified type name of this instance.

Declaration
public override string ToString()
Returns
Type Description
string

A string containing a fully qualified type name.

Overrides
ValueType.ToString()

Operators

| Edit this page View Source

operator +(GorgonRange, GorgonRange)

Implements the operator +.

Declaration
public static GorgonRange operator +(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left range.

GorgonRange right

The right range.

Returns
Type Description
GorgonRange

The result of the operator.

| Edit this page View Source

operator /(GorgonRange, int)

Implements the operator /.

Declaration
public static GorgonRange operator /(GorgonRange left, int scalar)
Parameters
Type Name Description
GorgonRange left

The left range.

int scalar

The right scalar value.

Returns
Type Description
GorgonRange

The result of the operator.

| Edit this page View Source

operator ==(GorgonRange, GorgonRange)

Implements the operator ==.

Declaration
public static bool operator ==(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left.

GorgonRange right

The right.

Returns
Type Description
bool

The result of the operator.

| Edit this page View Source

operator >(GorgonRange, GorgonRange)

Implements the operator >.

Declaration
public static bool operator >(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left instance to compare.

GorgonRange right

The right instance to compare.

Returns
Type Description
bool

true if left is greater than right.

| Edit this page View Source

operator >=(GorgonRange, GorgonRange)

Implements the operator >=.

Declaration
public static bool operator >=(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left instance to compare.

GorgonRange right

The right instance to compare.

Returns
Type Description
bool

true if left is greater than right.

| Edit this page View Source

implicit operator GorgonRangeD(GorgonRange)

Performs an explicit conversion from GorgonRange to GorgonRangeD.

Declaration
public static implicit operator GorgonRangeD(GorgonRange range)
Parameters
Type Name Description
GorgonRange range

The range.

Returns
Type Description
GorgonRangeD

The result of the conversion.

| Edit this page View Source

implicit operator GorgonRangeF(GorgonRange)

Performs an explicit conversion from GorgonRange to GorgonRangeF.

Declaration
public static implicit operator GorgonRangeF(GorgonRange range)
Parameters
Type Name Description
GorgonRange range

The range.

Returns
Type Description
GorgonRangeF

The result of the conversion.

| Edit this page View Source

implicit operator GorgonRangeM(GorgonRange)

Performs an explicit conversion from GorgonRange to GorgonRangeM.

Declaration
public static implicit operator GorgonRangeM(GorgonRange range)
Parameters
Type Name Description
GorgonRange range

The range.

Returns
Type Description
GorgonRangeM

The result of the conversion.

| Edit this page View Source

operator !=(GorgonRange, GorgonRange)

Implements the operator ==.

Declaration
public static bool operator !=(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left.

GorgonRange right

The right.

Returns
Type Description
bool

The result of the operator.

| Edit this page View Source

operator <(GorgonRange, GorgonRange)

Implements the operator >.

Declaration
public static bool operator <(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left instance to compare.

GorgonRange right

The right instance to compare.

Returns
Type Description
bool

true if left is greater than right.

| Edit this page View Source

operator <=(GorgonRange, GorgonRange)

Implements the operator >=.

Declaration
public static bool operator <=(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left instance to compare.

GorgonRange right

The right instance to compare.

Returns
Type Description
bool

true if left is greater than right.

| Edit this page View Source

operator *(GorgonRange, GorgonRange)

Implements the operator *.

Declaration
public static GorgonRange operator *(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left range.

GorgonRange right

The right range.

Returns
Type Description
GorgonRange

The result of the operator.

| Edit this page View Source

operator *(GorgonRange, int)

Implements the operator *.

Declaration
public static GorgonRange operator *(GorgonRange left, int scalar)
Parameters
Type Name Description
GorgonRange left

The left range.

int scalar

The right scalar value.

Returns
Type Description
GorgonRange

The result of the operator.

| Edit this page View Source

operator *(int, GorgonRange)

Implements the operator *.

Declaration
public static GorgonRange operator *(int scalar, GorgonRange right)
Parameters
Type Name Description
int scalar

The scalar value.

GorgonRange right

The right scalar value.

Returns
Type Description
GorgonRange

The result of the operator.

| Edit this page View Source

operator -(GorgonRange, GorgonRange)

Implements the operator -.

Declaration
public static GorgonRange operator -(GorgonRange left, GorgonRange right)
Parameters
Type Name Description
GorgonRange left

The left range.

GorgonRange right

The right range.

Returns
Type Description
GorgonRange

The result of the operator.

Implements

IGorgonEquatableByRef<T>
IEquatable<T>
IComparable<T>

Extension Methods

GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author