Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DiagLinkedList.cs
Go to the documentation of this file.
3
4namespace System.Diagnostics;
5
6internal sealed class DiagLinkedList<T> : IEnumerable<T>, IEnumerable
7{
9
11
13
15 {
16 }
17
19 {
21 }
22
24 {
25 _last = (_first = new DiagNode<T>(e.Current));
26 while (e.MoveNext())
27 {
28 _last.Next = new DiagNode<T>(e.Current);
29 _last = _last.Next;
30 }
31 }
32
33 public void Clear()
34 {
35 lock (this)
36 {
37 _first = (_last = null);
38 }
39 }
40
42 {
43 if (_first == null)
44 {
45 _first = (_last = newNode);
46 return;
47 }
48 _last.Next = newNode;
49 _last = newNode;
50 }
51
52 public void Add(T value)
53 {
55 lock (this)
56 {
58 }
59 }
60
62 {
63 lock (this)
64 {
65 for (DiagNode<T> diagNode = _first; diagNode != null; diagNode = diagNode.Next)
66 {
67 if (compare(value, diagNode.Value))
68 {
69 return false;
70 }
71 }
74 return true;
75 }
76 }
77
79 {
80 lock (this)
81 {
83 if (diagNode == null)
84 {
85 return default(T);
86 }
87 if (compare(diagNode.Value, value))
88 {
89 _first = diagNode.Next;
90 if (_first == null)
91 {
92 _last = null;
93 }
94 return diagNode.Value;
95 }
96 for (DiagNode<T> next = diagNode.Next; next != null; next = next.Next)
97 {
98 if (compare(next.Value, value))
99 {
100 diagNode.Next = next.Next;
101 if (_last == next)
102 {
103 _last = diagNode;
104 }
105 return next.Value;
106 }
107 diagNode = next;
108 }
109 return default(T);
110 }
111 }
112
114 {
115 return new Enumerator<T>(_first);
116 }
117
122
127}
T Remove(T value, Func< T, T, bool > compare)
void UnsafeAdd(DiagNode< T > newNode)
bool AddIfNotExist(T value, Func< T, T, bool > compare)
new IEnumerator< T > GetEnumerator()