Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GroupCollection.cs
Go to the documentation of this file.
5
7
8[DebuggerDisplay("Count = {Count}")]
10public class GroupCollection : IList<Group>, ICollection<Group>, IEnumerable<Group>, IEnumerable, IReadOnlyList<Group>, IReadOnlyCollection<Group>, IList, ICollection, IReadOnlyDictionary<string, Group>, IEnumerable<KeyValuePair<string, Group>>, IReadOnlyCollection<KeyValuePair<string, Group>>
11{
12 private sealed class Enumerator : IEnumerator<Group>, IEnumerator, IDisposable, IEnumerator<KeyValuePair<string, Group>>
13 {
14 private readonly GroupCollection _collection;
15
16 private int _index;
17
19 {
20 get
21 {
23 {
25 }
26 return _collection[_index];
27 }
28 }
29
42
43 object IEnumerator.Current => Current;
44
50
51 public bool MoveNext()
52 {
54 if (_index >= count)
55 {
56 return false;
57 }
58 _index++;
59 return _index < count;
60 }
61
63 {
64 _index = -1;
65 }
66
68 {
69 }
70 }
71
72 private readonly Match _match;
73
74 private readonly Hashtable _captureMap;
75
76 private Group[] _groups;
77
78 public bool IsReadOnly => true;
79
80 public int Count => _match._matchcount.Length;
81
82 public Group this[int groupnum] => GetGroup(groupnum);
83
84 public Group this[string groupname]
85 {
86 get
87 {
88 if (_match._regex != null)
89 {
91 }
92 return Group.s_emptyGroup;
93 }
94 }
95
96 public bool IsSynchronized => false;
97
98 public object SyncRoot => _match;
99
101 {
102 get
103 {
104 return this[index];
105 }
106 set
107 {
109 }
110 }
111
112 bool IList.IsFixedSize => true;
113
114 object? IList.this[int index]
115 {
116 get
117 {
118 return this[index];
119 }
120 set
121 {
123 }
124 }
125
127 {
128 get
129 {
130 int i = 0;
131 while (i < Count)
132 {
133 yield return GetGroup(i).Name;
134 int num = i + 1;
135 i = num;
136 }
137 }
138 }
139
141 {
142 get
143 {
144 int i = 0;
145 while (i < Count)
146 {
147 yield return GetGroup(i);
148 int num = i + 1;
149 i = num;
150 }
151 }
152 }
153
155 {
156 _match = match;
157 _captureMap = caps;
158 }
159
160 internal void Reset()
161 {
162 _groups = null;
163 }
164
166 {
167 return new Enumerator(this);
168 }
169
174
176 {
177 if (_captureMap != null)
178 {
179 if (_captureMap.TryGetValue<int>(groupnum, out var value))
180 {
181 return GetGroupImpl(value);
182 }
183 }
184 else if ((uint)groupnum < _match._matchcount.Length)
185 {
186 return GetGroupImpl(groupnum);
187 }
188 return Group.s_emptyGroup;
189 }
190
192 {
193 if (groupnum == 0)
194 {
195 return _match;
196 }
197 if (_groups == null)
198 {
199 _groups = new Group[_match._matchcount.Length - 1];
200 for (int i = 0; i < _groups.Length; i++)
201 {
202 string name = _match._regex.GroupNameFromNumber(i + 1);
204 }
205 }
206 return _groups[groupnum - 1];
207 }
208
209 public void CopyTo(Array array, int arrayIndex)
210 {
211 if (array == null)
212 {
214 }
215 int num = arrayIndex;
216 for (int i = 0; i < Count; i++)
217 {
218 array.SetValue(this[i], num);
219 num++;
220 }
221 }
222
223 public void CopyTo(Group[] array, int arrayIndex)
224 {
225 if (array == null)
226 {
228 }
230 {
231 throw new ArgumentOutOfRangeException("arrayIndex");
232 }
233 if (array.Length - arrayIndex < Count)
234 {
236 }
237 int num = arrayIndex;
238 for (int i = 0; i < Count; i++)
239 {
240 array[num] = this[i];
241 num++;
242 }
243 }
244
246 {
247 for (int i = 0; i < Count; i++)
248 {
249 if (EqualityComparer<Group>.Default.Equals(this[i], item))
250 {
251 return i;
252 }
253 }
254 return -1;
255 }
256
261
262 void IList<Group>.RemoveAt(int index)
263 {
265 }
266
271
276
278 {
279 return ((IList<Group>)this).IndexOf(item) >= 0;
280 }
281
286
291
296
297 bool IList.Contains(object value)
298 {
299 if (value is Group item)
300 {
301 return ((ICollection<Group>)this).Contains(item);
302 }
303 return false;
304 }
305
306 int IList.IndexOf(object value)
307 {
308 if (!(value is Group item))
309 {
310 return -1;
311 }
312 return ((IList<Group>)this).IndexOf(item);
313 }
314
319
324
329
334
335 public bool TryGetValue(string key, [NotNullWhen(true)] out Group? value)
336 {
337 Group group = this[key];
338 if (group == Group.s_emptyGroup)
339 {
340 value = null;
341 return false;
342 }
343 value = group;
344 return true;
345 }
346
347 public bool ContainsKey(string key)
348 {
350 }
351}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static string NotSupported_ReadOnlyCollection
Definition SR.cs:28
static string Arg_ArrayPlusOffTooSmall
Definition SR.cs:16
static string EnumNotStarted
Definition SR.cs:30
Definition SR.cs:7
void CopyTo(Array array, int arrayIndex)
bool TryGetValue(string key, [NotNullWhen(true)] out Group? value)
void CopyTo(Group[] array, int arrayIndex)
static readonly Group s_emptyGroup
Definition Group.cs:5
int GroupNumberFromName(string name)
Definition Regex.cs:306
static void ThrowArgumentNullException(ExceptionArgument arg)
void Insert(int index, T item)