MyCaffe  1.11.8.27
Deep learning software for Windows C# programmers.
RawProtoCollection.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace MyCaffe.basecode
7{
11 public class RawProtoCollection : IEnumerable<RawProto>
12 {
13 List<RawProto> m_rgItems = new List<RawProto>();
14
19 {
20 }
21
25 public int Count
26 {
27 get { return m_rgItems.Count; }
28 }
29
35 public RawProto this[int nIdx]
36 {
37 get { return m_rgItems[nIdx]; }
38 set { m_rgItems[nIdx] = value; }
39 }
40
46 public void Insert(int nIdx, RawProto p)
47 {
48 m_rgItems.Insert(nIdx, p);
49 }
50
55 public void Add(RawProto p)
56 {
57 m_rgItems.Add(p);
58 }
59
64 public void Add(RawProtoCollection col)
65 {
66 foreach (RawProto rp in col)
67 {
68 m_rgItems.Add(rp);
69 }
70 }
71
78 public void Add(string strName, string strVal, RawProto.TYPE type)
79 {
80 m_rgItems.Add(new RawProto(strName, strVal, null, type));
81 }
82
88 public void Add(string strName, string strVal)
89 {
90 m_rgItems.Add(new RawProto(strName, strVal));
91 }
92
98 public void Add(string strName, object val)
99 {
100 if (val == null)
101 return;
102
103 m_rgItems.Add(new RawProto(strName, val.ToString()));
104 }
105
112 public void Add<T>(string strName, List<T> rg)
113 {
114 if (rg == null || rg.Count == 0)
115 return;
116
117 foreach (T t in rg)
118 {
119 string strVal = t.ToString();
120
121 if (typeof(T) == typeof(string))
122 strVal = "\"" + strVal + "\"";
123
124 m_rgItems.Add(new RawProto(strName, strVal));
125 }
126 }
127
133 public bool Remove(RawProto p)
134 {
135 return m_rgItems.Remove(p);
136 }
137
142 public void RemoveAt(int nIdx)
143 {
144 m_rgItems.RemoveAt(nIdx);
145 }
146
150 public void Clear()
151 {
152 m_rgItems.Clear();
153 }
154
159 public IEnumerator<RawProto> GetEnumerator()
160 {
161 return m_rgItems.GetEnumerator();
162 }
163
168 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
169 {
170 return m_rgItems.GetEnumerator();
171 }
172 }
173}
The RawProtoCollection class is a list of RawProto objects.
void Add(string strName, object val)
Creates a new RawProto and adds it to this collection.
IEnumerator< RawProto > GetEnumerator()
Returns the enumerator for the collection.
bool Remove(RawProto p)
Removes a RawProto from the collection.
void Add(string strName, string strVal)
Creates a new RawProto and adds it to this collection.
void RemoveAt(int nIdx)
Removes the RawProto at a given index in the collection.
void Add(RawProto p)
Adds a RawProto to the collection.
void Insert(int nIdx, RawProto p)
Inserts a new RawProto into the collection at a given index.
RawProtoCollection()
The RawProtoCollection constructor.
void Add< T >(string strName, List< T > rg)
Creates a new RawProto for each element in rg and gives each the name strName, and add all to this co...
int Count
Returns the number of items in the collection.
void Add(string strName, string strVal, RawProto.TYPE type)
Creates a new RawProto and adds it to this collection.
void Clear()
Removes all items from the collection.
void Add(RawProtoCollection col)
Adds all elements of a RawProtoCollection to this collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
TYPE
Defines the type of a RawProto node.
Definition: RawProto.cs:27
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12