-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathInterval.cs
41 lines (34 loc) · 925 Bytes
/
Interval.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hexer
{
public class Interval<T> where T : IComparable<T>
{
public Interval(T min, T max)
{
Min = min;
Max = max;
}
public T Min { get; set; }
public T Max { get; set; }
public override string ToString()
{
return String.Format("[{0} - {1}]", Min, Max);
}
public Boolean IsValid()
{
return Min.CompareTo(Max) <= 0;
}
public Boolean Contains(T value)
{
return (Min.CompareTo(value) <= 0) && (value.CompareTo(Max) <= 0);
}
public Boolean IsInside(Interval<T> Range)
{
return this.IsValid() && Range.IsValid() && Range.Contains(this.Min) && Range.Contains(this.Max);
}
}
}