using UnityEngine;
using System.Collections.Generic;

public static class DictionaryExtensions 
{
    /// <summary>
    /// Note - assumes TKey does not need deep copying.
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TValue"></typeparam>
    /// <param name="dictionary"></param>
    /// <returns></returns>
    public static Dictionary<TKey, TValue> DeepCopy<TKey, TValue>(this Dictionary<TKey, TValue> dictionary) where TValue : ISupportsDeepCopy<TValue>
    {
        var result = new Dictionary<TKey, TValue>();

        foreach(var item in dictionary)
        {
            result.Add(item.Key, item.Value.DeepCopy());
        }

        return result;
    }

}
