本文整理汇总了C#中Interval.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# Interval.Intersect方法的具体用法?C# Interval.Intersect怎么用?C# Interval.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interval
的用法示例。
在下文中一共展示了Interval.Intersect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NonEmpty_NotIntersectingInterval__ReturnsEmptyInterval
public void NonEmpty_NotIntersectingInterval__ReturnsEmptyInterval()
{
// (-10; 10)
var a = new Interval(-10, false, 10, false);
// (-100; -10)
var b = new Interval(-100, false, -10, false);
Assert.IsTrue(a.Intersect(b).IsEmpty);
Assert.IsTrue(b.Intersect(a).IsEmpty);
// [-10; 10)
a = new Interval(-10, true, 10, false);
// (-100; -10)
b = new Interval(-100, false, -10, false);
Assert.IsTrue(a.Intersect(b).IsEmpty);
Assert.IsTrue(b.Intersect(a).IsEmpty);
// (-10; 10)
a = new Interval(-10, false, 10, false);
// (-100; -10]
b = new Interval(-100, false, -10, true);
Assert.IsTrue(a.Intersect(b).IsEmpty);
Assert.IsTrue(b.Intersect(a).IsEmpty);
}
示例2: NonEmpty_IntersectingInterval__ReturnsIntersection
public void NonEmpty_IntersectingInterval__ReturnsIntersection()
{
// (-10; 10)
var a = new Interval(-10, 10);
// (-11; -9)
var b = new Interval(-11, -9);
Assert.AreEqual(new Interval(-10, -9), a.Intersect(b));
Assert.AreEqual(new Interval(-10, -9), b.Intersect(a));
// [-10; 10)
a = new Interval(-10, true, 10, false);
// (-100; -10]
b = new Interval(-100, false, -10, true);
Assert.AreEqual(new Interval(-10, true, -10, true), a.Intersect(b));
Assert.AreEqual(new Interval(-10, true, -10, true), b.Intersect(a));
}
示例3: Self__ReturnsSelf
public void Self__ReturnsSelf()
{
var a = new Interval(-10, 10);
Assert.AreEqual(a, a.Intersect(a));
}