-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathInteractiveLineGen.LineList.cs
More file actions
42 lines (37 loc) · 1.19 KB
/
InteractiveLineGen.LineList.cs
File metadata and controls
42 lines (37 loc) · 1.19 KB
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
namespace TSLab.Script.Handlers
{
public sealed partial class InteractiveLineGen
{
private sealed class LineList : BaseList
{
private readonly double m_a;
private readonly double m_b;
public LineList(double a, double b, int count, int minIndex, int maxIndex)
: base(count, minIndex, maxIndex)
{
m_a = a;
m_b = b;
}
public override int IndexOf(double item)
{
var minValue = GetValue(MinIndex);
var maxValue = GetValue(MaxIndex);
if (minValue > maxValue)
{
var value = minValue;
minValue = maxValue;
maxValue = value;
}
if (item >= minValue && item <= maxValue)
for (var i = MinIndex; i <= MaxIndex; i++)
if (GetValue(i) == item)
return i;
return -1;
}
protected override double GetValue(int index)
{
return m_a * index + m_b;
}
}
}
}