Struct Interval
An interval [a,b] along the real line, where either endpoint may
be infinite.
struct Interval(T)
if (isSigned!T);
Fields
Name | Type | Description |
a
|
T | The interval endpoints.
|
b
|
T | The interval endpoints.
|
Properties
Name | Type | Description |
isInfinite [get]
|
bool | Determine whether the interval is infinite. This is true if:
- a is infinite, b is finite
- a is finite, b is infinite
- a and b are infinite, but have opposite sign.
If T is an integer type, this is always false.
|
isOrdered [get]
|
bool | Determine whether this is an ordered interval, i.e.
whether a <= b.
|
length [get]
|
T | The length of the interval, defined as b-a.
|
Methods
Name | Description |
contains
|
Check whether the value x is contained in the interval,
i.e. whether a <= x <= b or b <= x <= a.
|
order
|
If a > b, swap the endpoints.
|
Examples
auto i1 = interval(1, 5);
assert (i1.length == 4);
auto i2 = interval(0, real.infinity);
assert (i2.isInfinite);