Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LinkedList.cs
Go to the documentation of this file.
4
6
9[DebuggerDisplay("Count = {Count}")]
10[TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
12{
14 {
15 private readonly LinkedList<T> _list;
16
18
19 private readonly int _version;
20
21 private T _current;
22
23 private int _index;
24
25 public T Current => _current;
26
28 {
29 get
30 {
31 if (_index == 0 || _index == _list.Count + 1)
32 {
34 }
35 return Current;
36 }
37 }
38
40 {
41 _list = list;
42 _version = list.version;
43 _node = list.head;
44 _current = default(T);
45 _index = 0;
46 }
47
48 public bool MoveNext()
49 {
50 if (_version != _list.version)
51 {
53 }
54 if (_node == null)
55 {
56 _index = _list.Count + 1;
57 return false;
58 }
59 _index++;
60 _current = _node.item;
61 _node = _node.next;
62 if (_node == _list.head)
63 {
64 _node = null;
65 }
66 return true;
67 }
68
70 {
71 if (_version != _list.version)
72 {
74 }
75 _current = default(T);
76 _node = _list.head;
77 _index = 0;
78 }
79
80 public void Dispose()
81 {
82 }
83
88
90 {
92 }
93 }
94
96
97 internal int count;
98
99 internal int version;
100
102
103 public int Count => count;
104
106
108 {
109 get
110 {
111 if (head != null)
112 {
113 return head.prev;
114 }
115 return null;
116 }
117 }
118
120
122
123 object ICollection.SyncRoot => this;
124
125 public LinkedList()
126 {
127 }
128
130 {
131 if (collection == null)
132 {
133 throw new ArgumentNullException("collection");
134 }
135 foreach (T item in collection)
136 {
137 AddLast(item);
138 }
139 }
140
142 {
143 _siInfo = info;
144 }
145
147 {
148 AddLast(value);
149 }
150
158
166
178
190
192 {
194 if (head == null)
195 {
197 }
198 else
199 {
202 }
203 return linkedListNode;
204 }
205
207 {
209 if (head == null)
210 {
212 }
213 else
214 {
216 head = node;
217 }
218 node.list = this;
219 }
220
222 {
224 if (head == null)
225 {
227 }
228 else
229 {
231 }
232 return linkedListNode;
233 }
234
236 {
238 if (head == null)
239 {
241 }
242 else
243 {
245 }
246 node.list = this;
247 }
248
249 public void Clear()
250 {
251 LinkedListNode<T> next = head;
252 while (next != null)
253 {
255 next = next.Next;
256 linkedListNode.Invalidate();
257 }
258 head = null;
259 count = 0;
260 version++;
261 }
262
263 public bool Contains(T value)
264 {
265 return Find(value) != null;
266 }
267
268 public void CopyTo(T[] array, int index)
269 {
270 if (array == null)
271 {
272 throw new ArgumentNullException("array");
273 }
274 if (index < 0)
275 {
277 }
278 if (index > array.Length)
279 {
281 }
282 if (array.Length - index < Count)
283 {
285 }
286 LinkedListNode<T> next = head;
287 if (next != null)
288 {
289 do
290 {
291 array[index++] = next.item;
292 next = next.next;
293 }
294 while (next != head);
295 }
296 }
297
299 {
300 LinkedListNode<T> next = head;
301 EqualityComparer<T> @default = EqualityComparer<T>.Default;
302 if (next != null)
303 {
304 if (value != null)
305 {
306 do
307 {
308 if (@default.Equals(next.item, value))
309 {
310 return next;
311 }
312 next = next.next;
313 }
314 while (next != head);
315 }
316 else
317 {
318 do
319 {
320 if (next.item == null)
321 {
322 return next;
323 }
324 next = next.next;
325 }
326 while (next != head);
327 }
328 }
329 return null;
330 }
331
333 {
334 if (head == null)
335 {
336 return null;
337 }
338 LinkedListNode<T> prev = head.prev;
340 EqualityComparer<T> @default = EqualityComparer<T>.Default;
341 if (linkedListNode != null)
342 {
343 if (value != null)
344 {
345 do
346 {
347 if (@default.Equals(linkedListNode.item, value))
348 {
349 return linkedListNode;
350 }
352 }
353 while (linkedListNode != prev);
354 }
355 else
356 {
357 do
358 {
359 if (linkedListNode.item == null)
360 {
361 return linkedListNode;
362 }
364 }
365 while (linkedListNode != prev);
366 }
367 }
368 return null;
369 }
370
372 {
373 return new Enumerator(this);
374 }
375
380
381 public bool Remove(T value)
382 {
384 if (linkedListNode != null)
385 {
387 return true;
388 }
389 return false;
390 }
391
397
398 public void RemoveFirst()
399 {
400 if (head == null)
401 {
403 }
405 }
406
407 public void RemoveLast()
408 {
409 if (head == null)
410 {
412 }
414 }
415
417 {
418 if (info == null)
419 {
420 throw new ArgumentNullException("info");
421 }
422 info.AddValue("Version", version);
423 info.AddValue("Count", count);
424 if (count != 0)
425 {
426 T[] array = new T[count];
427 CopyTo(array, 0);
428 info.AddValue("Data", array, typeof(T[]));
429 }
430 }
431
432 public virtual void OnDeserialization(object? sender)
433 {
434 if (_siInfo == null)
435 {
436 return;
437 }
438 int @int = _siInfo.GetInt32("Version");
439 if (_siInfo.GetInt32("Count") != 0)
440 {
441 T[] array = (T[])_siInfo.GetValue("Data", typeof(T[]));
442 if (array == null)
443 {
445 }
446 for (int i = 0; i < array.Length; i++)
447 {
448 AddLast(array[i]);
449 }
450 }
451 else
452 {
453 head = null;
454 }
455 version = @int;
456 _siInfo = null;
457 }
458
468
477
479 {
480 if (node.next == node)
481 {
482 head = null;
483 }
484 else
485 {
486 node.next.prev = node.prev;
487 node.prev.next = node.next;
488 if (head == node)
489 {
490 head = node.next;
491 }
492 }
493 node.Invalidate();
494 count--;
495 version++;
496 }
497
499 {
500 if (node == null)
501 {
502 throw new ArgumentNullException("node");
503 }
504 if (node.list != null)
505 {
507 }
508 }
509
511 {
512 if (node == null)
513 {
514 throw new ArgumentNullException("node");
515 }
516 if (node.list != this)
517 {
519 }
520 }
521
523 {
524 if (array == null)
525 {
526 throw new ArgumentNullException("array");
527 }
528 if (array.Rank != 1)
529 {
531 }
532 if (array.GetLowerBound(0) != 0)
533 {
535 }
536 if (index < 0)
537 {
539 }
540 if (array.Length - index < Count)
541 {
543 }
544 if (array is T[] array2)
545 {
547 return;
548 }
549 if (!(array is object[] array3))
550 {
552 }
553 LinkedListNode<T> next = head;
554 try
555 {
556 if (next != null)
557 {
558 do
559 {
560 array3[index++] = next.item;
561 next = next.next;
562 }
563 while (next != head);
564 }
565 }
567 {
569 }
570 }
571
576}
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
void AddLast(LinkedListNode< T > node)
void InternalInsertNodeToEmptyList(LinkedListNode< T > newNode)
void Remove(LinkedListNode< T > node)
virtual void OnDeserialization(object? sender)
void InternalInsertNodeBefore(LinkedListNode< T > node, LinkedListNode< T > newNode)
LinkedListNode< T > AddBefore(LinkedListNode< T > node, T value)
LinkedList(SerializationInfo info, StreamingContext context)
LinkedListNode< T > AddFirst(T value)
void AddFirst(LinkedListNode< T > node)
void ValidateNewNode(LinkedListNode< T > node)
LinkedList(IEnumerable< T > collection)
void AddAfter(LinkedListNode< T > node, LinkedListNode< T > newNode)
void AddBefore(LinkedListNode< T > node, LinkedListNode< T > newNode)
void InternalRemoveNode(LinkedListNode< T > node)
LinkedListNode< T > AddAfter(LinkedListNode< T > node, T value)
void ValidateNode(LinkedListNode< T > node)
void CopyTo(T[] array, int index)
LinkedListNode< T >? FindLast(T value)
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
LinkedListNode< T > AddLast(T value)
LinkedListNode< T >? Find(T value)
static string Serialization_MissingValues
Definition SR.cs:74
static string ExternalLinkedListNode
Definition SR.cs:60
static string LinkedListNodeIsAttached
Definition SR.cs:64
static string Argument_InvalidArrayType
Definition SR.cs:54
static string Arg_NonZeroLowerBound
Definition SR.cs:14
static string LinkedListEmpty
Definition SR.cs:62
static string ArgumentOutOfRange_BiggerThanCollection
Definition SR.cs:56
static string InvalidOperation_EnumFailedVersion
Definition SR.cs:44
static string Arg_RankMultiDimNotSupported
Definition SR.cs:18
static string InvalidOperation_EnumOpCantHappen
Definition SR.cs:48
static string Arg_InsufficientSpace
Definition SR.cs:26
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7
void CopyTo(T[] array, int arrayIndex)
new IEnumerator< T > GetEnumerator()
void GetObjectData(SerializationInfo info, StreamingContext context)