Reputation: 1257
i'm currently working on an experimental setup, that is used to write complex microstructures into glass with a femtosecond laser.
The output power of the laser is regulated by a filterwheel which i control from my (C# console)application. As I initially do not know the position of the wheel, I need to initalize it on startup, by measuring the power for a predefined number of points on the wheel.
This information (power values and their corresponding position on the wheel) should be stored during runtime. So basically if a certain output power is requested, the controller will look up the two points in between which the desired value can be found and then increments the position until it is reached.
This is something i would usually achieve using a database. As the initialization takes place on every startup and it does not need to be persisted, i would probably prefer to just keep it as an in-memory list.
So my question is:
Is it possible to somehow "index" the power values to retrieve them quickly?
Upvotes: 0
Views: 118
Reputation: 7692
Some time ago I wrote a small post on the different list types in dotnet with pros and cons.
http://www.selfelected.com/list-of-list-and-collection-classes-in-dotnet-11-45/
Upvotes: 1
Reputation: 13907
You may look at using a SortedDictionary<int, int>
if you're going to have to calculate "in-between" values for keys.
Look at the similar question here for an example on finding points between two keys using a SortedDictionary
Upvotes: 2
Reputation: 32681
if you want to map each key to a value you should use Dictionary<key,value>
Upvotes: 0
Reputation: 245419
A Dictionary<int, int>
would probably be your best bet. Of course, you could switch out the key/value types to match your data if it isn't int
s.
Upvotes: 3