-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIntRange.cs
68 lines (59 loc) · 1.36 KB
/
IntRange.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
namespace camera_connection
{
using System;
public class IntRange
{
private int max;
private int min;
public IntRange(int min, int max)
{
this.min = min;
this.max = max;
}
public bool IsInside(IntRange range)
{
return (this.IsInside(range.min) && this.IsInside(range.max));
}
public bool IsInside(int x)
{
return ((x >= this.min) && (x <= this.max));
}
public bool IsOverlapping(IntRange range)
{
if ((!this.IsInside(range.min) && !this.IsInside(range.max)) && !range.IsInside(this.min))
{
return range.IsInside(this.max);
}
return true;
}
public int Length
{
get
{
return (this.max - this.min);
}
}
public int Max
{
get
{
return this.max;
}
set
{
this.max = value;
}
}
public int Min
{
get
{
return this.min;
}
set
{
this.min = value;
}
}
}
}