Class IntInterval
Represents an integer interval with bounded/unbounded and inclusive/exclusive end points.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public class IntInterval : Interval<int, int, IntervalEndpoint<int>, IntInterval>, IInterval<int, int, IntervalEndpoint<int>, IntInterval>
Constructors
View SourceIntInterval(IntervalEndpoint<Int32>, IntervalEndpoint<Int32>)
Initializes a new instance of the Int
Declaration
public IntInterval(IntervalEndpoint<int> leftEndpoint, IntervalEndpoint<int> rightEndpoint)
Parameters
Type | Name | Description |
---|---|---|
Interval |
leftEndpoint | Left endpoint. |
Interval |
rightEndpoint | Right endpoint. |
IntInterval(Int32, Boolean, Boolean, Int32, Boolean, Boolean)
Initializes a new instance of the Int
Declaration
public IntInterval(int leftPoint, bool leftInclusive, bool leftBounded, int rightPoint, bool rightInclusive, bool rightBounded)
Parameters
Type | Name | Description |
---|---|---|
System. |
leftPoint | Left bound point (or min value if unbound). |
System. |
leftInclusive | Whether left point is inclusive (always false if unbound). |
System. |
leftBounded | Whether left point is bounded. |
System. |
rightPoint | Right bound point (or min value if unbound). |
System. |
rightInclusive | Whether right point is inclusive (always false if unbound). |
System. |
rightBounded | Whether right point is bounded. |
IntInterval(Int32, Boolean, Int32, Boolean)
Initializes a new instance of the Int
Declaration
public IntInterval(int leftPoint, bool leftInclusive, int rightPoint, bool rightInclusive)
Parameters
Type | Name | Description |
---|---|---|
System. |
leftPoint | Left bound point. |
System. |
leftInclusive | Whether left point is inclusive. |
System. |
rightPoint | Right bound point. |
System. |
rightInclusive | Whether right point is inclusive. |
IntInterval(Int32, Int32)
Initializes a new instance of the Int
Declaration
public IntInterval(int leftPoint, int rightPoint)
Parameters
Type | Name | Description |
---|---|---|
System. |
leftPoint | Left bound point. |
System. |
rightPoint | Right bound point. |
Remarks
Defaults to inclusive.
Fields
View SourceEmpty
Canonical empty instance (bounded, non-inclusive, single point).
Declaration
public static readonly IntInterval Empty
Field Value
Type | Description |
---|---|
Int |
Infinite
Canonical infinite interval (unbounded on both ends).
Declaration
public static readonly IntInterval Infinite
Field Value
Type | Description |
---|---|
Int |
Zero
Zero interval (unbounded but inclusive, zero value).
Declaration
public static readonly IntInterval Zero
Field Value
Type | Description |
---|---|
Int |
Properties
View SourcePointMaxValue
Gets the point maximum value.
Declaration
protected override int PointMaxValue { get; }
Property Value
Type | Description |
---|---|
System. |
Overrides
PointMinValue
Gets the point minimum value.
Declaration
protected override int PointMinValue { get; }
Property Value
Type | Description |
---|---|
System. |
Overrides
SpanMaxValue
Gets the span maximum value.
Declaration
protected override int SpanMaxValue { get; }
Property Value
Type | Description |
---|---|
System. |
Overrides
SpanMinValue
Gets the span minimum value.
Declaration
protected override int SpanMinValue { get; }
Property Value
Type | Description |
---|---|
System. |
Overrides
SpanZeroValue
Gets the span zero value.
Declaration
protected override int SpanZeroValue { get; }
Property Value
Type | Description |
---|---|
System. |
Overrides
Methods
View SourceComparePoints(Int32, Int32)
Compare points.
Declaration
protected override int ComparePoints(int a, int b)
Parameters
Type | Name | Description |
---|---|---|
System. |
a | First point. |
System. |
b | Second point. |
Returns
Type | Description |
---|---|
System. |
Less (-1), greater (+1) or equal (0). |
Overrides
Coverage(IEnumerable<IntInterval>)
Determine coverage from minimum left to maximum right for a set of given intervals.
Declaration
public static IntInterval Coverage(IEnumerable<IntInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Int |
intervals | The set of intervals. |
Returns
Type | Description |
---|---|
Int |
Interval from minimum left to maximum right value. |
Remarks
Returns empty interval when sequence is empty or contains only empty intervals.
Difference(Int32, Int32)
Determine span between two given points.
Declaration
protected override int Difference(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System. |
x | First point. |
System. |
y | Second point. |
Returns
Type | Description |
---|---|
System. |
Span between points. |
Overrides
LeftBounded(Int32)
Constructor helper for left-bound instances.
Declaration
public static IntInterval LeftBounded(int left)
Parameters
Type | Name | Description |
---|---|---|
System. |
left | Left bound point. |
Returns
Type | Description |
---|---|
Int |
A left-bound instance of the Int |
Remarks
Defaults to inclusive.
LeftBounded(Int32, Boolean)
Constructor helper for left-bound instances.
Declaration
public static IntInterval LeftBounded(int left, bool inclusive)
Parameters
Type | Name | Description |
---|---|---|
System. |
left | Left bound point. |
System. |
inclusive | Whether left point is inclusive. |
Returns
Type | Description |
---|---|
Int |
A left-bound instance of the Int |
Merge(IEnumerable<IntInterval>)
Merges a specified set of int intervals into a set of non-overlapping int intervals that cover the specified intervals.
Declaration
public static IEnumerable<IntInterval> Merge(IEnumerable<IntInterval> intervals)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Int |
intervals | A set of intervals to cover. |
Returns
Type | Description |
---|---|
IEnumerable<Int |
Set of non-overlapping intervals that cover the given intervals. |
NegateSpan(Int32)
Negate span.
Declaration
protected override int NegateSpan(int span)
Parameters
Type | Name | Description |
---|---|---|
System. |
span | Span to be negated. |
Returns
Type | Description |
---|---|
System. |
Negated span.. |
Overrides
RightBounded(Int32)
Constructor helper for right-bound instances.
Declaration
public static IntInterval RightBounded(int right)
Parameters
Type | Name | Description |
---|---|---|
System. |
right | Right bound point. |
Returns
Type | Description |
---|---|
Int |
A right-bound instance of the Int |
Remarks
Defaults to inclusive.
RightBounded(Int32, Boolean)
Constructor helper for right-bound instances.
Declaration
public static IntInterval RightBounded(int right, bool inclusive)
Parameters
Type | Name | Description |
---|---|---|
System. |
right | Right bound point. |
System. |
inclusive | Whether right point is inclusive. |
Returns
Type | Description |
---|---|
Int |
A right-bound instance of the Int |
Scale(Int32, Int32)
Scale endpoints by span distances.
Declaration
public override IntInterval Scale(int left, int right)
Parameters
Type | Name | Description |
---|---|---|
System. |
left | Span by which to scale left. |
System. |
right | Span by which to scale right. |
Returns
Type | Description |
---|---|
Int |
Scaled interval. |
Overrides
Scale(Single, Single)
Scale endpoints by factors.
Declaration
public override IntInterval Scale(float left, float right)
Parameters
Type | Name | Description |
---|---|---|
System. |
left | Factor by which to scale left. |
System. |
right | Factor by which to scale right. |
Returns
Type | Description |
---|---|
Int |
Scaled interval. |
Overrides
ScaleSpan(Int32, Double)
Scale a span by a given factor.
Declaration
protected override int ScaleSpan(int span, double factor)
Parameters
Type | Name | Description |
---|---|---|
System. |
span | Span value. |
System. |
factor | Factor by which to scale. |
Returns
Type | Description |
---|---|
System. |
Scaled span. |
Overrides
Translate(Int32)
Translate by a span distance.
Declaration
public override IntInterval Translate(int span)
Parameters
Type | Name | Description |
---|---|---|
System. |
span | Span by which to translate. |
Returns
Type | Description |
---|---|
Int |
Translated interval. |
Overrides
Remarks
Unbound points do not change.
TranslatePoint(Int32, Int32)
Translate point by given span.
Declaration
protected override int TranslatePoint(int point, int span)
Parameters
Type | Name | Description |
---|---|---|
System. |
point | Point value. |
System. |
span | Span by which to translate. |
Returns
Type | Description |
---|---|
System. |
Translated point. |