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

◆ this[object key]

object? System.Collections.Specialized.ListDictionary.this[object key]
getset

Implements System.Collections.IDictionary.

Definition at line 231 of file ListDictionary.cs.

232 {
233 get
234 {
235 if (key == null)
236 {
237 throw new ArgumentNullException("key");
238 }
239 DictionaryNode next = head;
240 if (comparer == null)
241 {
242 while (next != null)
243 {
244 object key2 = next.key;
245 if (key2.Equals(key))
246 {
247 return next.value;
248 }
249 next = next.next;
250 }
251 }
252 else
253 {
254 while (next != null)
255 {
256 object key3 = next.key;
257 if (comparer.Compare(key3, key) == 0)
258 {
259 return next.value;
260 }
261 next = next.next;
262 }
263 }
264 return null;
265 }
266 set
267 {
268 if (key == null)
269 {
270 throw new ArgumentNullException("key");
271 }
272 version++;
273 DictionaryNode dictionaryNode = null;
274 DictionaryNode next;
275 for (next = head; next != null; next = next.next)
276 {
277 object key2 = next.key;
278 if ((comparer == null) ? key2.Equals(key) : (comparer.Compare(key2, key) == 0))
279 {
280 break;
281 }
282 dictionaryNode = next;
283 }
284 if (next != null)
285 {
286 next.value = value;
287 return;
288 }
289 DictionaryNode dictionaryNode2 = new DictionaryNode();
290 dictionaryNode2.key = key;
291 dictionaryNode2.value = value;
292 if (dictionaryNode != null)
293 {
294 dictionaryNode.next = dictionaryNode2;
295 }
296 else
297 {
298 head = dictionaryNode2;
299 }
300 count++;
301 }
302 }
int Compare(object? x, object? y)