I need an alternate for a dictionary, because duplicates are needed. The reason for that is: I need to search for the best route. To do that I am creating a population with 20 individuals for example. Each individual has its own route and to each route is a fitness calculated. To be able to sort the route by the fitness I am creating a dictionary. Now I am iterating over generations while sorting the dictionary and adding new routes to it every iteration. However the dictionary is deleting duplicates, which should not be done because the code might throw the best route multiple times.
I already read something about a lookup, and a linked list but don't really have knowledge about it. Or maybe a tuple? Anyone who knows better what might help?
This is my code though: Well its not the hole code just showing the dictionary to avoid misunderstanding.
List<List<Point3d>> currentGeneration = new List<List<Point3d>>(cGP.Count);
cGP.ForEach((item) => {currentGeneration.Add(new List<Point3d>(item));});
List<double> currentFitness = cGF.ToList();
Dictionary<List<Point3d>, double> dictionary = new Dictionary<List<Point3d>, double>();
foreach(List<Point3d> individual in currentGeneration)
{
foreach(double individualsFitness in currentFitness)
{
if(!dictionary.ContainsKey(individual))
{
if(!dictionary.ContainsValue(individualsFitness))
{
dictionary.Add(individual, individualsFitness);
}
}
}
}