GenerateGraph.AddToDictionary C# (CSharp) Method

AddToDictionary() public method

Given a dictionary that maps a Node to the list of Triangles that contain that Node on a side, add the value to the list of Triangles that the key currently maps to
public AddToDictionary ( Dictionary &dict, Node, key, Triangle, value ) : void
dict Dictionary // the dictionary that maps a Node to the list of Triangles that contain // that Node on a side //
key Node, a Node
value Triangle, a Triangle to add to the list of Triangles that the key currently maps to
return void
    public void AddToDictionary(ref Dictionary<Node, List<Triangle>> dict, Node key, Triangle value)
    {
        if (dict.ContainsKey (key)) {
            List<Triangle> currentNodes = dict[key];
            currentNodes.Add(value);
            dict[key] = currentNodes;
        } else {
            List<Triangle> newNodes = new List<Triangle>();
            newNodes.Add(value);
            dict.Add(key, newNodes);
        }
    }