Struct IntRange
Represents an integer range with minimum and maximum values.
Implements
IRange<System.Int32>
System.IFormattable
System.IEquatable<IntRange>
System.Collections.Generic.IEnumerable<System.Int32>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Mars.Numerics.Ranges
Assembly: Mars.Numerics.dll
Syntax
[Serializable]
public struct IntRange : IRange<int>, IFormattable, IEquatable<IntRange>, IEnumerable<int>, IEnumerable
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
Examples
// create [1, 10] range
var range1 = new IntRange(1, 10);
// create [5, 15] range
var range2 = new IntRange(5, 15);
check if values is inside of the first range
if (range1.IsInside(7))
{
// ...
}
// check if the second range is inside of the first range
if (range1.IsInside(range2))
{
// ...
}
// check if two ranges overlap
if (range1.IsOverlapping(range2))
{
// ...
}
Constructors
| Improve this Doc View SourceIntRange(Int32, Int32)
Initializes a new instance of the IntRange class.
Declaration
public IntRange(int min, int max)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | min | Minimum value of the range. |
System.Int32 | max | Maximum value of the range. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
Properties
| Improve this Doc View SourceLength
Gets the length of the range, defined as (max - min).
Declaration
public readonly int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceMax
Maximum value of the range.
Declaration
public int Max { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Represents maximum value (right side limit) of the range [min, max].
See Also
| Improve this Doc View SourceMin
Minimum value of the range.
Declaration
public int Min { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Represents minimum value (left side limit) of the range [min, max].
See Also
Methods
| Improve this Doc View SourceEquals(IntRange)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(IntRange other)
Parameters
Type | Name | Description |
---|---|---|
IntRange | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
System.Boolean |
true if the current object is equal to the other parameter; otherwise, false.
|
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceEquals(Object)
Determines whether the specified System.Object, is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The System.Object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
true if the specified System.Object is equal to this instance; otherwise, false .
|
Overrides
System.ValueType.Equals(System.Object)
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceGetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
public IEnumerator<int> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Int32> | An System.Collections.IEnumerator object that can be used to iterate through the collection. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceGetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
System.ValueType.GetHashCode()
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceIntersection(IntRange)
Computes the intersection between two ranges.
Declaration
public IntRange Intersection(IntRange range)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range | The second range for which the intersection should be calculated. |
Returns
Type | Description |
---|---|
IntRange |
An new IntRange structure containing the intersection
between this range and the range given as argument.
|
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceIsInside(IntRange)
Check if the specified range is inside of the range.
Declaration
public bool IsInside(IntRange range)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range | Range to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified range is inside of the range or false otherwise. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceIsInside(Int32)
Check if the specified value is inside of the range.
Declaration
public bool IsInside(int x)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Value to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified value is inside of the range or false otherwise. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceIsOverlapping(IntRange)
Check if the specified range overlaps with the range.
Declaration
public bool IsOverlapping(IntRange range)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range | Range to check for overlapping. |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified range overlaps with the range or false otherwise. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Overrides
System.ValueType.ToString()
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceToString(String, IFormatProvider)
Returns a System.String that represents this instance.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The format. |
System.IFormatProvider | formatProvider | The format provider. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
Operators
| Improve this Doc View SourceEquality(IntRange, IntRange)
Determines whether two instances are equal.
Declaration
public static bool operator ==(IntRange range1, IntRange range2)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range1 | |
IntRange | range2 |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceImplicit(IntRange to DoubleRange)
Performs an implicit conversion from IntRange to DoubleRange.
Declaration
public static implicit operator DoubleRange(IntRange range)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range | The range. |
Returns
Type | Description |
---|---|
DoubleRange | The result of the conversion. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceImplicit(IntRange to FloatRange)
Performs an implicit conversion from IntRange to FloatRange.
Declaration
public static implicit operator FloatRange(IntRange range)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range | The range. |
Returns
Type | Description |
---|---|
FloatRange | The result of the conversion. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
| Improve this Doc View SourceInequality(IntRange, IntRange)
Determines whether two instances are not equal.
Declaration
public static bool operator !=(IntRange range1, IntRange range2)
Parameters
Type | Name | Description |
---|---|---|
IntRange | range1 | |
IntRange | range2 |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |
Remarks
The class represents an integer range with inclusive limits, where
both minimum and maximum values of the range are included into it.
Mathematical notation of such range is [min, max].
See Also
Implements
System.IFormattable
System.IEquatable<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable