using System; using System.Collections.Generic; namespace HeuristicLab.Analysis.FitnessLandscape { public static class DictionaryExtensions { public static TValue GetValueOrDefault(this IDictionary d, TKey key, Func provider) { var value = provider(); d.TryGetValue(key, out value); return value; } public static TValue GetValueOrDefault(this IDictionary d, TKey key, TValue def) { var value = def; d.TryGetValue(key, out value); return value; } public static TValue GetValueOrDefault(this IDictionary d, TKey key) { var value = default(TValue); d.TryGetValue(key, out value); return value; } } }