blob: 3ff5bcb7d0dbd938c0de704ef412c6a9640052cf (
plain)
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
69
70
71
72
73
74
75
76
|
using System;
using System.Collections.Generic;
namespace Lextm.SharpSnmpLib.Mib
{
public class ValueRanges: List<ValueRange>
{
public bool IsSizeDeclaration { get; internal set; }
public ValueRanges(bool isSizeDecl = false)
{
IsSizeDeclaration = isSizeDecl;
}
public bool Contains(Int64 value)
{
foreach (ValueRange range in this)
{
if (range.Contains(value))
{
return true;
}
}
return false;
}
}
public class ValueRange
{
private readonly Int64 _start;
private readonly Int64? _end;
public ValueRange(Int64 first, Int64? second)
{
_start = first;
_end = second;
}
public Int64 Start
{
get { return _start; }
}
public Int64? End
{
get { return _end; }
}
public bool IntersectsWith(ValueRange other)
{
if (this._end == null)
{
return other.Contains(this._start);
}
else if (other._end == null)
{
return this.Contains(other._start);
}
return (this._start <= other.End) && (this._end >= other._start);
}
public bool Contains(Int64 value)
{
if (_end == null)
{
return value == _start;
}
else
{
return (_start <= value) && (value <= _end);
}
}
}
}
|