I'm a former C++/STL programmer trying to code a fast marching algorithm using c#/.NET technology...
I'm searching for an equivalent of STL method "map::insert" that insert a value at given key if not exists, else returns an iterator to the existing key-value pair.
The only way I found does this with two lookups : one inside TryGetValue and another one in Add method :
List<Point> list;
if (!_dictionary.TryGetValue (pcost, out list))
{
list = new List<Point> ();
dictionary.Add (pcost, list);
}
list.Add (new Point { X = n.x, Y = n.y });
Is there something that explains why this is not possible using .NET containers ? Or did I missed some point ?
Thanks.