Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 5e8a627

Browse files
committed
Generalized some methods that have IList parameters
1 parent d5efc45 commit 5e8a627

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

ColorSharp/ColorSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<Compile Include="src\Illuminants\D65.cs" />
7070
<Compile Include="src\MatchingFunctions\CIE1931XYZ1NmMatchingFunctionX.cs" />
7171
<Compile Include="src\MatchingFunctions\CIE1931XYZ1NmMatchingFunctionY.cs" />
72-
<Compile Include="src\MatchingFunctions\CIE1931XYZ51NmMatchingFunctionZ.cs" />
72+
<Compile Include="src\MatchingFunctions\CIE1931XYZ1NmMatchingFunctionZ.cs" />
7373
</ItemGroup>
7474
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
7575
<ItemGroup>

ColorSharp/src/ColorSpaces/CIExyY.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ ref SortedSharkfin1Nm
102102
/**
103103
* Computes the 'sharkin' points.
104104
*/
105-
static void computeSharkfin(double[] mfX, double[] mfY, double[] mfZ, ref xyYPoint[] Sharkfin, ref xyYPoint[] SortedSharkfin)
105+
static void computeSharkfin(IList<double> mfX, IList<double> mfY, IList<double> mfZ, ref xyYPoint[] Sharkfin, ref xyYPoint[] SortedSharkfin)
106106
{
107-
var n = mfX.Length;
107+
var n = mfX.Count;
108108

109109
Sharkfin = new xyYPoint[n];
110110

ColorSharp/src/MatchingFunctions/RegularMatchingFunction.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929

3030
using System;
31+
using System.Collections.Generic;
32+
using System.Collections.ObjectModel;
3133

3234

3335
namespace Litipk.ColorSharp
@@ -61,7 +63,7 @@ public class RegularMatchingFunction : AMatchingFunction
6163
/**
6264
* <value>Data points</value>
6365
*/
64-
public readonly double[] Amplitudes;
66+
public readonly ReadOnlyCollection<double> Amplitudes;
6567
#endregion
6668

6769

@@ -73,12 +75,12 @@ public class RegularMatchingFunction : AMatchingFunction
7375
* <param name="maxWaveLength">Upper boundary of the matching function's support.</param>
7476
* <param name="amplitudes">Data points.</param>
7577
*/
76-
public RegularMatchingFunction (double minWaveLength, double maxWaveLength, double[] amplitudes)
78+
public RegularMatchingFunction (double minWaveLength, double maxWaveLength, IList<double> amplitudes)
7779
{
7880
MinWaveLength = minWaveLength;
7981
MaxWaveLength = maxWaveLength;
80-
NmPerStep = (maxWaveLength - minWaveLength) / (amplitudes.Length - 1);
81-
Amplitudes = amplitudes;
82+
NmPerStep = (maxWaveLength - minWaveLength) / (amplitudes.Count - 1);
83+
Amplitudes = new ReadOnlyCollection<double> (amplitudes);
8284
}
8385

8486
/**
@@ -87,12 +89,12 @@ public RegularMatchingFunction (double minWaveLength, double maxWaveLength, doub
8789
* <param name="amplitudes">Data points.</param>
8890
* <param name="nmPerStep">Number of nanometers between data points.</param>
8991
*/
90-
public RegularMatchingFunction (double minWaveLength, double[] amplitudes, double nmPerStep)
92+
public RegularMatchingFunction (double minWaveLength, IList<double> amplitudes, double nmPerStep)
9193
{
9294
NmPerStep = nmPerStep;
9395
MinWaveLength = minWaveLength;
94-
MaxWaveLength = minWaveLength + nmPerStep * (amplitudes.Length - 1);
95-
Amplitudes = amplitudes;
96+
MaxWaveLength = minWaveLength + nmPerStep * (amplitudes.Count - 1);
97+
Amplitudes = new ReadOnlyCollection<double> (amplitudes);
9698
}
9799

98100
#endregion
@@ -108,7 +110,7 @@ public override double EvaluateAt (double waveLength)
108110
if (waveLength >= MinWaveLength && waveLength <= MaxWaveLength) {
109111
double dblIndex = (waveLength - MinWaveLength) / NmPerStep;
110112
double floorIndex = Math.Floor (dblIndex);
111-
uint uIndex = (uint)floorIndex;
113+
int uIndex = (int)floorIndex;
112114

113115
if (dblIndex - floorIndex <= 2*double.Epsilon) {
114116
return Amplitudes [uIndex];
@@ -144,7 +146,7 @@ public override double GetSupportMaxValue ()
144146
*/
145147
public override int GetNumberOfDataPoints()
146148
{
147-
return Amplitudes.Length;
149+
return Amplitudes.Count;
148150
}
149151

150152
#endregion

0 commit comments

Comments
 (0)