MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DictionaryMap.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace MyCaffe.basecode
7{
8#pragma warning disable 1591
9
10 public class DictionaryMap<T>
11 {
12 Dictionary<int, T> m_rgMap = new Dictionary<int, T>();
13 T m_dfDefault;
14
15 public DictionaryMap(T dfDefault)
16 {
17 m_dfDefault = dfDefault;
18 }
19
20 public DictionaryMap(int nCount, T dfDefault)
21 {
22 m_dfDefault = dfDefault;
23
24 for (int i = 0; i < nCount; i++)
25 {
26 m_rgMap.Add(i, dfDefault);
27 }
28 }
29
30 public T this[int nIdx]
31 {
32 get
33 {
34 if (m_rgMap.ContainsKey(nIdx))
35 return m_rgMap[nIdx];
36
37 return m_dfDefault;
38 }
39
40 set
41 {
42 if (m_rgMap.ContainsKey(nIdx))
43 m_rgMap[nIdx] = value;
44 else
45 m_rgMap.Add(nIdx, value);
46 }
47 }
48
49 public int Count
50 {
51 get { return m_rgMap.Count; }
52 }
53
54 public void Clear()
55 {
56 m_rgMap.Clear();
57 }
58
59 public Dictionary<int, T> Map
60 {
61 get { return m_rgMap; }
62 }
63 }
64#pragma warning restore 1591
65}
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12