I am looking for the best way to create a "best" list for a group of lists. Here's the shorthand of what I have:
public class Tank
{
public int id;
public string name;
List<Volume> volume; //Volume for each day for two years
}
public class Volume
{
public DateTime date;
public double volume;
public string status;
}
public class Master
{
public DateTime date;
public string bestTankName;
public int id;
public double bestVolume;
}
Main
{
List<Master> masterVolume = new List<Volume>();
List<Tank> Tanks = SQLQueryToGetVolumes();
for (int i = 720; i < 0; i--)
{
masterVolume.Add(new Master
{
date = DateTime.Today.AddDays(-i)
});
}
//for each date in the master volume list, I need to get the
//highest volume from the other lists for that day,
//along with the other information associated with that day
foreach (Master m in masterVolume)
{
//Compare all the Tanks and get the best one for that day*******
}
}
I have made a mess of foreach loops that result in roughly 100 Billion computations for all of the data that needs to be processed. There are thousands of these groups of tanks that need to processed in this way.
Is there a better way to go about doing this? I need to get the highest volume, for every day. I then need to record that volume along with the other tank class properties into a master list without it taking 15 hours.
Any help or direction would be much appreciated.