Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ this[object key]

object? System.Collections.ListDictionaryInternal.this[object key]
getset

Implements System.Collections.IDictionary.

Definition at line 236 of file ListDictionaryInternal.cs.

237 {
238 get
239 {
240 if (key == null)
241 {
242 throw new ArgumentNullException("key", SR.ArgumentNull_Key);
243 }
244 for (DictionaryNode next = head; next != null; next = next.next)
245 {
246 if (next.key.Equals(key))
247 {
248 return next.value;
249 }
250 }
251 return null;
252 }
253 set
254 {
255 if (key == null)
256 {
257 throw new ArgumentNullException("key", SR.ArgumentNull_Key);
258 }
259 version++;
260 DictionaryNode dictionaryNode = null;
261 DictionaryNode next = head;
262 while (next != null && !next.key.Equals(key))
263 {
264 dictionaryNode = next;
265 next = next.next;
266 }
267 if (next != null)
268 {
269 next.value = value;
270 return;
271 }
272 DictionaryNode dictionaryNode2 = new DictionaryNode();
273 dictionaryNode2.key = key;
274 dictionaryNode2.value = value;
275 if (dictionaryNode != null)
276 {
277 dictionaryNode.next = dictionaryNode2;
278 }
279 else
280 {
281 head = dictionaryNode2;
282 }
283 count++;
284 }
285 }