Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/DictionaryExtensions.cs @ 12095

Last change on this file since 12095 was 8744, checked in by epitzer, 12 years ago

Improve Information Analyzer #1696

  • Configurable discretized or full quantile analysis
  • Configurable shape size
  • Include peak information values and deltas in results
File size: 837 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace HeuristicLab.Analysis.FitnessLandscape {
7  public static class DictionaryExtensions {
8    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> d, TKey key, Func<TValue> provider) {
9      var value = provider();
10      d.TryGetValue(key, out value);
11      return value;
12    }
13    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> d, TKey key, TValue def) {
14      var value = def;
15      d.TryGetValue(key, out value);
16      return value;
17    }
18    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> d, TKey key) {
19      var value = default(TValue);
20      d.TryGetValue(key, out value);
21      return value;
22    }
23  }
24}
Note: See TracBrowser for help on using the repository browser.