Struct DoubleRange
Represents a double range with minimum and maximum values.
Assembly: Mars.Numerics.dll
Syntax
public struct DoubleRange : IRange<double>, IFormattable, IEquatable<DoubleRange>
Examples
// create [0.25, 1.5] range
var range1 = new DoubleRange(0.25, 1.5);
// create [1.00, 2.25] range
var range2 = new DoubleRange(1.00, 2.25);
// check if values is inside of the first range
if (range1.IsInside(0.75))
{
// ...
}
// 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
DoubleRange(Double, Double)
Declaration
public DoubleRange(double min, double max)
Parameters
Type |
Name |
Description |
System.Double |
min |
Minimum value of the range. |
System.Double |
max |
Maximum value of the range. |
Properties
Length
Gets the length of the range, defined as (max - min).
Declaration
public double Length { get; }
Property Value
Type |
Description |
System.Double |
|
Max
Maximum value of the range.
Declaration
public double Max { get; set; }
Property Value
Type |
Description |
System.Double |
|
Min
Minimum value of the range.
Declaration
public double Min { get; set; }
Property Value
Type |
Description |
System.Double |
|
Methods
Equals(DoubleRange)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(DoubleRange other)
Parameters
Type |
Name |
Description |
DoubleRange |
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.
|
Equals(Object)
Determines whether the specified , is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
The to compare with this instance. |
Returns
Type |
Description |
System.Boolean |
true if the specified is equal to this instance; otherwise, false .
|
GetHashCode()
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.
|
Intersection(DoubleRange)
Computes the intersection between two ranges.
Declaration
public DoubleRange Intersection(DoubleRange range)
Parameters
Type |
Name |
Description |
DoubleRange |
range |
The second range for which the intersection should be calculated. |
Returns
Type |
Description |
DoubleRange |
An new IntRange structure containing the intersection
between this range and the range given as argument.
|
IsInside(DoubleRange)
Check if the specified range is inside of the range.
Declaration
public bool IsInside(DoubleRange range)
Parameters
Type |
Name |
Description |
DoubleRange |
range |
Range to check. |
Returns
Type |
Description |
System.Boolean |
True if the specified range is inside of the range or false otherwise.
|
IsInside(Double)
Check if the specified value is inside of the range.
Declaration
public bool IsInside(double x)
Parameters
Type |
Name |
Description |
System.Double |
x |
Value to check. |
Returns
Type |
Description |
System.Boolean |
True if the specified value is inside of the range or false otherwise.
|
IsOverlapping(DoubleRange)
Check if the specified range overlaps with the range.
Declaration
public bool IsOverlapping(DoubleRange range)
Parameters
Type |
Name |
Description |
DoubleRange |
range |
Range to check for overlapping. |
Returns
Type |
Description |
System.Boolean |
True if the specified range overlaps with the range or false otherwise.
|
ToArray()
Converts this
DoubleRange to a
System.Double[] of length 2 (using new [] { min, max
}).
Declaration
public double[] ToArray()
Returns
Type |
Description |
System.Double[] |
The result of the conversion. |
ToIntRange(Boolean)
Converts this double-precision range into an
IntRange.
Declaration
public IntRange ToIntRange(bool provideInnerRange)
Parameters
Type |
Name |
Description |
System.Boolean |
provideInnerRange |
Specifies if inner integer range must be returned or outer range.
|
Returns
Type |
Description |
IntRange |
Returns integer version of the range. |
ToString()
Returns a that represents this instance.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
A that represents this instance.
|
Returns a that represents this instance.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.String |
format |
The format. |
IFormatProvider |
formatProvider |
The format provider. |
Returns
Type |
Description |
System.String |
A that represents this instance.
|
Operators
Equality(DoubleRange, DoubleRange)
Determines whether two instances are equal.
Declaration
public static bool operator ==(DoubleRange range1, DoubleRange range2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implicit(DoubleRange to Double[])
Performs an implicit conversion from
DoubleRange to
System.Double[].
Declaration
public static implicit operator double[](DoubleRange range)
Parameters
Returns
Type |
Description |
System.Double[] |
The result of the conversion. |
Inequality(DoubleRange, DoubleRange)
Determines whether two instances are not equal.
Declaration
public static bool operator !=(DoubleRange range1, DoubleRange range2)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implements
IFormattable
IEquatable<>
Extension Methods
See Also