Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MatchCollection.cs
Go to the documentation of this file.
4
6
7[DebuggerDisplay("Count = {Count}")]
10{
11 private sealed class Enumerator : IEnumerator<Match>, IEnumerator, IDisposable
12 {
13 private readonly MatchCollection _collection;
14
15 private int _index;
16
18 {
19 get
20 {
21 if (_index < 0)
22 {
24 }
26 }
27 }
28
29 object IEnumerator.Current => Current;
30
36
37 public bool MoveNext()
38 {
39 if (_index == -2)
40 {
41 return false;
42 }
43 _index++;
45 if (match == null)
46 {
47 _index = -2;
48 return false;
49 }
50 return true;
51 }
52
54 {
55 _index = -1;
56 }
57
59 {
60 }
61 }
62
63 private readonly Regex _regex;
64
65 private readonly List<Match> _matches;
66
67 private readonly string _input;
68
69 private int _startat;
70
71 private int _prevlen;
72
73 private bool _done;
74
75 public bool IsReadOnly => true;
76
77 public int Count
78 {
79 get
80 {
82 return _matches.Count;
83 }
84 }
85
86 public virtual Match this[int i]
87 {
88 get
89 {
90 Match result = null;
91 if (i < 0 || (result = GetMatch(i)) == null)
92 {
94 }
95 return result;
96 }
97 }
98
99 public bool IsSynchronized => false;
100
101 public object SyncRoot => this;
102
104 {
105 get
106 {
107 return this[index];
108 }
109 set
110 {
112 }
113 }
114
115 bool IList.IsFixedSize => true;
116
117 object? IList.this[int index]
118 {
119 get
120 {
121 return this[index];
122 }
123 set
124 {
126 }
127 }
128
129 internal MatchCollection(Regex regex, string input, int startat)
130 {
131 if ((uint)startat > (uint)input.Length)
132 {
134 }
135 _regex = regex;
136 _input = input;
138 _prevlen = -1;
139 _matches = new List<Match>();
140 _done = false;
141 }
142
144 {
145 return new Enumerator(this);
146 }
147
152
153 private Match GetMatch(int i)
154 {
155 if (_matches.Count > i)
156 {
157 return _matches[i];
158 }
159 if (_done)
160 {
161 return null;
162 }
163 Match match;
164 do
165 {
166 match = _regex.Run(quick: false, _prevlen, _input, 0, _input.Length, _startat);
167 if (!match.Success)
168 {
169 _done = true;
170 return null;
171 }
173 _prevlen = match.Length;
174 _startat = match._textpos;
175 }
176 while (_matches.Count <= i);
177 return match;
178 }
179
180 private void EnsureInitialized()
181 {
182 if (!_done)
183 {
184 GetMatch(int.MaxValue);
185 }
186 }
187
188 public void CopyTo(Array array, int arrayIndex)
189 {
192 }
193
194 public void CopyTo(Match[] array, int arrayIndex)
195 {
198 }
199
201 {
203 return _matches.IndexOf(item);
204 }
205
210
211 void IList<Match>.RemoveAt(int index)
212 {
214 }
215
220
225
231
236
241
246
247 bool IList.Contains(object value)
248 {
249 if (value is Match)
250 {
251 return ((ICollection<Match>)this).Contains((Match)value);
252 }
253 return false;
254 }
255
256 int IList.IndexOf(object value)
257 {
258 if (!(value is Match item))
259 {
260 return -1;
261 }
262 return ((IList<Match>)this).IndexOf(item);
263 }
264
269
274
279}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
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 EnumNotStarted
Definition SR.cs:30
Definition SR.cs:7
void CopyTo(Match[] array, int arrayIndex)
MatchCollection(Regex regex, string input, int startat)
void CopyTo(Array array, int arrayIndex)
Match Run(bool quick, int prevlen, string input, int beginning, int length, int startat)
Definition Regex.cs:337
static void ThrowArgumentOutOfRangeException(ExceptionArgument arg)
void Insert(int index, T item)