forked from tslab-hub/handlers
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInteractiveLineGen.BaseList.cs
More file actions
124 lines (100 loc) · 3.46 KB
/
InteractiveLineGen.BaseList.cs
File metadata and controls
124 lines (100 loc) · 3.46 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.Collections;
using System.Collections.Generic;
namespace TSLab.Script.Handlers
{
public sealed partial class InteractiveLineGen
{
private abstract class BaseList : IList<double>
{
protected BaseList(int count)
: this(count, 0, count - 1)
{
}
protected BaseList(int count, int minIndex, int maxIndex)
{
if (count == 0)
{
if (minIndex != -1)
throw new ArgumentOutOfRangeException(nameof(minIndex));
if (maxIndex != -1)
throw new ArgumentOutOfRangeException(nameof(maxIndex));
}
else if (count > 0)
{
if (minIndex < 0)
throw new ArgumentOutOfRangeException(nameof(minIndex));
if (maxIndex >= count)
throw new ArgumentOutOfRangeException(nameof(maxIndex));
if (minIndex > maxIndex)
throw new ArgumentOutOfRangeException(nameof(maxIndex));
}
else
throw new ArgumentOutOfRangeException(nameof(count));
Count = count;
MinIndex = minIndex;
MaxIndex = maxIndex;
}
public IEnumerator<double> GetEnumerator()
{
if (Count > 0)
{
for (var i = 0; i < MinIndex; i++)
yield return double.NaN;
for (var i = MinIndex; i <= MaxIndex; i++)
yield return GetValue(i);
for (var i = MaxIndex + 1; i < Count; i++)
yield return double.NaN;
}
else
yield return double.NaN;
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Add(double item)
{
throw new NotSupportedException();
}
public void Clear()
{
throw new NotSupportedException();
}
public bool Contains(double item)
{
return IndexOf(item) >= 0;
}
public void CopyTo(double[] array, int arrayIndex)
{
throw new NotSupportedException();
}
public bool Remove(double item)
{
throw new NotSupportedException();
}
public int Count { get; }
public bool IsReadOnly
{
get { return true; }
}
public abstract int IndexOf(double item);
public void Insert(int index, double item)
{
throw new NotSupportedException();
}
public void RemoveAt(int index)
{
throw new NotSupportedException();
}
public double this[int index]
{
get { return index >= MinIndex && index <= MaxIndex ? GetValue(index) : double.NaN; }
set { throw new NotSupportedException(); }
}
protected int MinIndex { get; }
protected int MaxIndex { get; }
protected abstract double GetValue(int index);
}
}
}