本文整理汇总了C#中Range.Union方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Union方法的具体用法?C# Range.Union怎么用?C# Range.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.Union方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnionWithTouchShouldUnion
public void UnionWithTouchShouldUnion(int s1, int e1, int s2, int e2, int s, int e)
{
var r1 = new Range<int>(s1, e1);
var r2 = new Range<int>(s2, e2);
var r = e >= 0 ? (Range<int>?)new Range<int>(s, e) : null;
Assert.AreEqual(r, r1.Union(r2, i => i + 1));
Assert.AreEqual(r, r2.Union(r1, i => i + 1));
}
示例2: GetUnionWithNoCommonality
public void GetUnionWithNoCommonality()
{
var range = new Range<int>(3, 6);
Assert.IsNull(range.Union(new Range<int>(7, 10)));
}
示例3: GetUnionWithCurrentRangeHavingStartAndTargetHavingEnd
public void GetUnionWithCurrentRangeHavingStartAndTargetHavingEnd()
{
var range = new Range<int>(3, 6);
var union = range.Union(new Range<int>(4, 10));
Assert.AreEqual(3, union.Start);
Assert.AreEqual(10, union.End);
}
示例4: GetUnionWhereTargetDefinesUnion
public void GetUnionWhereTargetDefinesUnion()
{
var range = new Range<int>(3, 6);
var union = range.Union(new Range<int>(1, 10));
Assert.AreEqual(1, union.Start);
Assert.AreEqual(10, union.End);
}
示例5: RangeUnion01Test
public void RangeUnion01Test()
{
Range<int> r1;
Range<int> r2;
r1 = new Range<int>(10, 20);
r2 = new Range<int>(10, 20);
Assert.AreEqual(new Range<int>(10, 20), r1.Union(r2, false));
r1 = new Range<int>(10, 20);
r2 = new Range<int>(20, 30);
Assert.AreEqual(new Range<int>(10, 30), r1.Union(r2, false));
r1 = new Range<int>(10, 20);
r2 = new Range<int>(12, 24);
Assert.AreEqual(new Range<int>(10, 24), r1.Union(r2, false));
r1 = new Range<int>(10, 20);
r2 = new Range<int>(8, 12);
Assert.AreEqual(new Range<int>(8, 20), r1.Union(r2, false));
r1 = new Range<int>(10, 20);
r2 = new Range<int>(12, 18);
Assert.AreEqual(new Range<int>(10, 20), r1.Union(r2, false));
r1 = new Range<int>(10, 20);
r2 = new Range<int>(8, 22);
Assert.AreEqual(new Range<int>(8, 22), r1.Union(r2, false));
}
示例6: RangeUnion02Test
public void RangeUnion02Test()
{
Range<int> r1;
Range<int> r2;
r1 = new Range<int>(5, 10);
r2 = new Range<int>(12, 16);
Range<int> union = r1.Union(r2, false);
}
示例7: Union
public void Union()
{
var r1 = new Range<int>(10, 20);
var r2 = new Range<int>(15, 25);
var union = r1.Union(r2);
Assert.AreEqual(10, union.Start);
Assert.AreEqual(25, union.End);
}