本文整理汇总了C#中Interval.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Interval.Contains方法的具体用法?C# Interval.Contains怎么用?C# Interval.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interval
的用法示例。
在下文中一共展示了Interval.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contains
public void Contains()
{
Interval interval = new Interval(0, 1, IntervalEndpoint.Closed, IntervalEndpoint.Open);
Assert.IsFalse(interval.Contains(-1));
Assert.IsTrue(interval.Contains(0));
Assert.IsTrue(interval.Contains(0.5));
Assert.IsFalse(interval.Contains(1));
Assert.IsFalse(interval.Contains(2));
}
示例2: Contains
public void Contains()
{
IInterval<int> interval = new Interval<int>(5, 10);
Assert.IsTrue(interval.Contains(5));
Assert.IsTrue(interval.Contains(7));
Assert.IsTrue(interval.Contains(10));
Assert.IsFalse(interval.Contains(4));
Assert.IsFalse(interval.Contains(11));
}
示例3: ContainsValue
public void ContainsValue()
{
var epsilon = 1E-12;
Interval x;
x = new Interval();
Assert.IsTrue(x.Contains(0));
Assert.IsFalse(x.Contains(0 + 2 * epsilon));
x = new Interval(-1, 1, epsilon);
Assert.IsTrue(x.Contains(0));
Assert.IsTrue(x.Contains(-1 - epsilon / 2));
Assert.IsFalse(x.Contains(3));
Assert.IsFalse(x.Contains(1 + 2 * epsilon));
}
示例4: CompareDecimals
protected ComparerResult CompareDecimals(Interval interval, decimal actual)
{
if (interval.Contains(actual))
return ComparerResult.Equality;
return new ComparerResult(interval.ToString());
}
示例5: Overlaps
private bool Overlaps(Interval interval, Interval resInterval)
{
if (interval.Contains(resInterval.Start)) return true;
if (interval.Contains(resInterval.End)) return true;
if (resInterval.Contains(interval.Start)) return true;
if (resInterval.Contains(interval.End)) return true;
return false;
}
示例6: ContainsTest_Bound_ExclusiveOnUpperExclusive
public void ContainsTest_Bound_ExclusiveOnUpperExclusive()
{
int lowerBound = 2;
BoundType lowerBoundType = BoundType.Inclusive;
int upperBound = 5;
BoundType upperBoundType = BoundType.Exclusive;
Interval<int> target = new Interval<int>(lowerBound, lowerBoundType, upperBound, upperBoundType);
IBound<int> bound = new Bound<int>(5, BoundType.Exclusive);
bool expected = true;
bool actual;
actual = target.Contains(bound);
Assert.AreEqual(expected, actual);
}
示例7: AtLeast
public void AtLeast()
{
var list = new int[] { 1, 2, 3 };
Assert.True(list.AtLeast(2));
Assert.True(list.AtLeast(3));
Assert.False(list.AtLeast(4));
Assert.True(list.AtLeast(2, i => i < 3));
Assert.False(list.AtLeast(3, i => i < 3));
// Should work for infinite sequences as well
Assert.True(1.Inc().AtLeast(2));
var interval = new Interval<int>(3, 7);
Assert.True(1.Inc().AtLeast(2, i => interval.Contains(i)));
}
示例8: IntervalContainment
public void IntervalContainment(int s1, int e1, int v, bool expected)
{
Interval<int> a = new Interval<int>(s1, e1);
if (expected)
Assert.True(a.Contains(v));
else
Assert.False(a.Contains(v));
}
示例9: GetIntersectionsWithinTime
/// <summary>
/// Liefert alle Intersections im Zeitintervall interval
/// </summary>
/// <param name="interval">Intervall in dem nach Intersections gesucht werden soll</param>
/// <returns>Eine Liste von Intersections die im Zeitintervall interval auf dieser Linie vorkommen</returns>
public List<Intersection> GetIntersectionsWithinTime(Interval<double> interval)
{
List<Intersection> toReturn = new List<Intersection>();
foreach (Intersection i in this.intersections)
{
if (this == i._aConnection)
{
if (interval.Contains(i._aTime))
{
toReturn.Add(i);
}
}
else
{
if (interval.Contains(i._bTime))
{
toReturn.Add(i);
}
}
}
return toReturn;
}
示例10: CheckContains
private void CheckContains(Interval interval1, Interval interval2, bool expextedResult)
{
Assert.AreEqual(interval1.Contains(interval2), expextedResult);
}
示例11: Contains_EmptyInterval_MaxValue
public void Contains_EmptyInterval_MaxValue()
{
var instant = Instant.MaxValue;
var interval = new Interval(instant, instant);
// This would have been true under Noda Time 1.x
Assert.IsFalse(interval.Contains(instant));
}
示例12: Contains_EmptyInterval
public void Contains_EmptyInterval()
{
var instant = NodaConstants.UnixEpoch;
var interval = new Interval(instant, instant);
Assert.IsFalse(interval.Contains(instant));
}
示例13: Contains_Infinite
public void Contains_Infinite()
{
var interval = new Interval(null, null);
Assert.IsTrue(interval.Contains(Instant.MaxValue));
Assert.IsTrue(interval.Contains(Instant.MinValue));
}
示例14: Contains
public void Contains(string candidateText, bool expectedResult)
{
var start = Instant.FromUtc(2000, 1, 1, 0, 0);
var end = Instant.FromUtc(2020, 1, 1, 0, 0);
var interval = new Interval(start, end);
var candidate = InstantPattern.ExtendedIsoPattern.Parse(candidateText).Value;
Assert.AreEqual(expectedResult, interval.Contains(candidate));
}
示例15: GetIntersectionsWithinArcLength
/// <summary>
/// Liefert alle Intersections im Bogenlängenintervall intervall
/// </summary>
/// <param name="interval">Bogenlängeintervall in dem die Intersections liegen sollen</param>
/// <returns>Eine Liste von Intersections, die im Bogenlängenintervall intervall liegen</returns>
public List<SpecificIntersection> GetIntersectionsWithinArcLength(Interval<double> interval)
{
List<SpecificIntersection> toReturn = new List<SpecificIntersection>();
foreach (Intersection i in this.intersections)
{
if (this == i._aConnection)
{
if (interval.Contains(i.aArcPosition))
{
toReturn.Add(new SpecificIntersection(this, i));
}
}
else
{
if (interval.Contains(i.bArcPosition))
{
toReturn.Add(new SpecificIntersection(this, i));
}
}
}
return toReturn;
}