本文整理汇总了C#中RangeCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# RangeCollection.Contains方法的具体用法?C# RangeCollection.Contains怎么用?C# RangeCollection.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RangeCollection
的用法示例。
在下文中一共展示了RangeCollection.Contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsTest
public void ContainsTest()
{
RangeCollection c = new RangeCollection();
c.Add(new AddressRange(1, 100));
c.Add(new AddressRange(-10, -1));
for (int i = -15; i < 120; i++)
{
bool shouldContain = (i >= -10 && i <= -1) || (i >= 1 && i <= 100);
Assert.AreEqual(shouldContain, c.Contains(new AddressRange(i, i)), "#1." + i);
}
}
示例2: LargeSequentialContains
public void LargeSequentialContains ()
{
RangeCollection range = new RangeCollection ();
int i, n = 1000000;
for (i = 0; i < n; i++) {
range.Add (i);
}
for (i = 0; i < n; i++) {
Assert.AreEqual (true, range.Contains (i));
}
}
示例3: NegativeIndices
public void NegativeIndices ()
{
RangeCollection c = new RangeCollection ();
c.Add (-10);
c.Add (-5);
c.Add (5);
c.Add (-8);
c.Add (10);
c.Add (-9);
c.Add (-11);
Assert.IsTrue (c.Contains(-10), "#1");
Assert.IsTrue (c.Contains(-5), "#2");
Assert.IsTrue (c.Contains(5), "#3");
Assert.IsTrue (c.Contains(-8), "#4");
Assert.AreEqual (4, c.RangeCount, "#5");
Assert.AreEqual (new RangeCollection.Range (-11, -8), c.Ranges[0], "#6");
Assert.AreEqual (new RangeCollection.Range (-5, -5), c.Ranges[1], "#7");
Assert.AreEqual (new RangeCollection.Range (5, 5), c.Ranges[2], "#8");
Assert.AreEqual (new RangeCollection.Range (10, 10), c.Ranges[3], "#9");
Assert.AreEqual (0, c.FindRangeIndexForValue (-9), "#10");
Assert.IsTrue (c.FindRangeIndexForValue (-7) < 0, "#11");
}
示例4: IPAddressRanges
public void IPAddressRanges ()
{
RangeCollection ranges = new RangeCollection ();
int start = GetAddress ("127.0.0.1");
int end = GetAddress ("127.0.0.50");
for (int i = start; i <= end; i++) {
ranges.Add (i);
}
Assert.IsTrue (ranges.Contains (GetAddress ("127.0.0.15")));
Assert.IsFalse (ranges.Contains (GetAddress ("127.0.0.0")));
Assert.IsFalse (ranges.Contains (GetAddress ("127.0.0.51")));
}
示例5: ContainsTest
public void ContainsTest()
{
var c = new RangeCollection();
c.Add(new AddressRange(1, 100));
c.Add(new AddressRange(-10, -1));
for (var i = -15; i < 120; i++)
{
var shouldContain = (i >= -10 && i <= -1) || (i >= 1 && i <= 100);
Assert.Equal(shouldContain, c.Contains(new AddressRange(i, i)));
}
}