Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ObjectCollection.cs
Go to the documentation of this file.
1
using
System.Collections
;
2
using
System.Collections.Generic
;
3
using
System.Diagnostics
;
4
5
namespace
System.Net.Http.Headers
;
6
7
[DebuggerDisplay(
"Count = {Count}"
)]
8
[
DebuggerTypeProxy
(
typeof
(
ObjectCollection<>
.DebugView))]
9
internal
sealed
class
ObjectCollection
<T> :
ICollection
<T>,
IEnumerable
<T>,
IEnumerable
where
T :
class
10
{
11
public
struct
Enumerator
:
IEnumerator
<T>,
IEnumerator
,
IDisposable
12
{
13
private
readonly
ObjectCollection<T>
_list
;
14
15
private
int
_index
;
16
17
private
T
_current
;
18
19
public
T
Current
=>
_current
;
20
21
object
IEnumerator.Current =>
_current
;
22
23
internal
Enumerator
(
ObjectCollection<T>
list
)
24
{
25
_list
=
list
;
26
_index
= 0;
27
_current
=
null
;
28
}
29
30
public
void
Dispose
()
31
{
32
}
33
34
public
bool
MoveNext
()
35
{
36
ObjectCollection<T>
list
=
_list
;
37
if
((uint)
_index
< (uint)
list
._size)
38
{
39
_current
= ((list._items
is
T[]
array
) ?
array
[
_index
] : ((
T
)
list
._items));
40
_index
++;
41
return
true
;
42
}
43
_index
= _list._size + 1;
44
_current
=
null
;
45
return
false
;
46
}
47
48
void
IEnumerator
.
Reset
()
49
{
50
_index
= 0;
51
_current
=
null
;
52
}
53
}
54
55
internal
sealed
class
DebugView
56
{
57
private
readonly
ObjectCollection<T>
_collection
;
58
59
[
DebuggerBrowsable
(
DebuggerBrowsableState
.RootHidden)]
60
public
T[] Items
61
{
62
get
63
{
64
T[]
array
=
new
T[
_collection
.
Count
];
65
_collection
.
CopyTo
(
array
, 0);
66
return
array
;
67
}
68
}
69
70
public
DebugView
(
ObjectCollection<T>
collection
)
71
{
72
_collection
=
collection
??
throw
new
ArgumentNullException
(
"collection"
);
73
}
74
}
75
76
private
readonly
Action<T>
_validator
;
77
78
internal
object
_items
;
79
80
internal
int
_size
;
81
82
public
int
Count
=>
_size
;
83
84
public
bool
IsReadOnly
=>
false
;
85
86
public
ObjectCollection
()
87
{
88
}
89
90
public
ObjectCollection
(
Action<T>
validator)
91
{
92
_validator
= validator;
93
}
94
95
public
void
Add
(T
item
)
96
{
97
if
(
_validator
==
null
)
98
{
99
if
(
item
==
null
)
100
{
101
throw
new
ArgumentNullException
(
"item"
);
102
}
103
}
104
else
105
{
106
_validator
(
item
);
107
}
108
if
(
_items
==
null
)
109
{
110
_items
=
item
;
111
_size
= 1;
112
return
;
113
}
114
if
(
_items
is
T val)
115
{
116
_items
=
new
T[4] { val,
item
,
null
,
null
};
117
_size
= 2;
118
return
;
119
}
120
T[]
array
= (T[])
_items
;
121
int
size =
_size
;
122
if
((uint)size < (uint)
array
.Length)
123
{
124
array
[size] =
item
;
125
}
126
else
127
{
128
T[]
array2
=
new
T[array.Length * 2];
129
Array
.
Copy
(
array
,
array2
, size);
130
_items
=
array2
;
131
array2
[size] =
item
;
132
}
133
_size
= size + 1;
134
}
135
136
public
void
Clear
()
137
{
138
_items
=
null
;
139
_size
= 0;
140
}
141
142
public
bool
Contains
(T
item
)
143
{
144
if
(
_size
> 0)
145
{
146
if
(!(
_items
is
T val))
147
{
148
if
(
_items
is
T[]
array
)
149
{
150
return
Array
.
IndexOf
(
array
,
item
, 0,
_size
) != -1;
151
}
152
return
false
;
153
}
154
return
val.Equals(
item
);
155
}
156
return
false
;
157
}
158
159
public
void
CopyTo
(T[]
array
,
int
arrayIndex
)
160
{
161
if
(
_items
is
T[]
sourceArray
)
162
{
163
Array
.
Copy
(
sourceArray
, 0,
array
,
arrayIndex
,
_size
);
164
}
165
else
if
(
array
==
null
||
_size
>
array
.Length -
arrayIndex
)
166
{
167
new
T[1] { (
T
)
_items
}.CopyTo(
array
,
arrayIndex
);
168
}
169
else
if
(
_size
== 1)
170
{
171
array
[
arrayIndex
] = (
T
)
_items
;
172
}
173
}
174
175
public
bool
Remove
(T
item
)
176
{
177
if
(
_items
is
T val)
178
{
179
if
(val.Equals(
item
))
180
{
181
_items
=
null
;
182
_size
= 0;
183
return
true
;
184
}
185
}
186
else
if
(
_items
is
T[]
array
)
187
{
188
int
num =
Array
.
IndexOf
(
array
,
item
, 0,
_size
);
189
if
(num != -1)
190
{
191
_size
--;
192
if
(num <
_size
)
193
{
194
Array
.
Copy
(
array
, num + 1,
array
, num,
_size
- num);
195
}
196
array
[
_size
] =
null
;
197
return
true
;
198
}
199
}
200
return
false
;
201
}
202
203
public
Enumerator
GetEnumerator
()
204
{
205
return
new
Enumerator
(
this
);
206
}
207
208
IEnumerator<T>
IEnumerable<T>
.
GetEnumerator
()
209
{
210
return
GetEnumerator
();
211
}
212
213
IEnumerator
IEnumerable
.
GetEnumerator
()
214
{
215
return
GetEnumerator
();
216
}
217
}
System.ArgumentNullException
Definition
ArgumentNullException.cs:10
System.Array.IndexOf
int IList. IndexOf(object value)
Definition
Array.cs:1228
System.Array.Copy
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition
Array.cs:624
System.Array
Definition
Array.cs:16
System.Collections.Generic.Dictionary.CopyTo
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
Definition
Dictionary.cs:959
System.Collections.Generic.Dictionary.Count
int Count
Definition
Dictionary.cs:682
System.Collections.Generic.Dictionary.GetEnumerator
Enumerator GetEnumerator()
Definition
Dictionary.cs:984
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Net.Http.Headers.ObjectCollection.DebugView._collection
readonly ObjectCollection< T > _collection
Definition
ObjectCollection.cs:57
System.Net.Http.Headers.ObjectCollection.DebugView.DebugView
DebugView(ObjectCollection< T > collection)
Definition
ObjectCollection.cs:70
System.Net.Http.Headers.ObjectCollection.DebugView
Definition
ObjectCollection.cs:56
System.Net.Http.Headers.ObjectCollection._size
int _size
Definition
ObjectCollection.cs:80
System.Net.Http.Headers.ObjectCollection.ObjectCollection
ObjectCollection(Action< T > validator)
Definition
ObjectCollection.cs:90
System.Net.Http.Headers.ObjectCollection._validator
readonly Action< T > _validator
Definition
ObjectCollection.cs:76
System.Net.Http.Headers.ObjectCollection.Contains
bool Contains(T item)
Definition
ObjectCollection.cs:142
System.Net.Http.Headers.ObjectCollection.Count
int Count
Definition
ObjectCollection.cs:82
System.Net.Http.Headers.ObjectCollection.CopyTo
void CopyTo(T[] array, int arrayIndex)
Definition
ObjectCollection.cs:159
System.Net.Http.Headers.ObjectCollection.Remove
bool Remove(T item)
Definition
ObjectCollection.cs:175
System.Net.Http.Headers.ObjectCollection.IsReadOnly
bool IsReadOnly
Definition
ObjectCollection.cs:84
System.Net.Http.Headers.ObjectCollection.Add
void Add(T item)
Definition
ObjectCollection.cs:95
System.Net.Http.Headers.ObjectCollection.GetEnumerator
Enumerator GetEnumerator()
Definition
ObjectCollection.cs:203
System.Net.Http.Headers.ObjectCollection.ObjectCollection
ObjectCollection()
Definition
ObjectCollection.cs:86
System.Net.Http.Headers.ObjectCollection.Clear
void Clear()
Definition
ObjectCollection.cs:136
System.Net.Http.Headers.ObjectCollection._items
object _items
Definition
ObjectCollection.cs:78
System.Net.Http.Headers.ObjectCollection
Definition
ObjectCollection.cs:10
System.Collections.Generic.ICollection
Definition
ICollection.cs:4
System.Collections.Generic.IEnumerable.GetEnumerator
new IEnumerator< T > GetEnumerator()
System.Collections.Generic.IEnumerable
Definition
IEnumerable.cs:4
System.Collections.Generic.IEnumerator
Definition
IEnumerator.cs:4
System.Collections.IEnumerator.Reset
void Reset()
System.IDisposable
Definition
IDisposable.cs:4
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Collections
Definition
BlockingCollection.cs:8
System.Diagnostics.DebuggerBrowsableState
DebuggerBrowsableState
Definition
DebuggerBrowsableState.cs:4
System.Diagnostics
Definition
AggregationManager.cs:6
System.Net.Http.Headers
Definition
AltSvcHeaderParser.cs:4
System.ExceptionArgument.list
@ list
System.ExceptionArgument.item
@ item
System.ExceptionArgument.arrayIndex
@ arrayIndex
System.ExceptionArgument.sourceArray
@ sourceArray
System.ExceptionArgument.collection
@ collection
System.ExceptionArgument.array
@ array
System.ConsoleKey.T
@ T
System.Net.Http.Headers.ObjectCollection.Enumerator.Enumerator
Enumerator(ObjectCollection< T > list)
Definition
ObjectCollection.cs:23
System.Net.Http.Headers.ObjectCollection.Enumerator.Current
T Current
Definition
ObjectCollection.cs:19
System.Net.Http.Headers.ObjectCollection.Enumerator._index
int _index
Definition
ObjectCollection.cs:15
System.Net.Http.Headers.ObjectCollection.Enumerator._list
readonly ObjectCollection< T > _list
Definition
ObjectCollection.cs:13
System.Net.Http.Headers.ObjectCollection.Enumerator.Dispose
void Dispose()
Definition
ObjectCollection.cs:30
System.Net.Http.Headers.ObjectCollection.Enumerator._current
T _current
Definition
ObjectCollection.cs:17
System.Net.Http.Headers.ObjectCollection.Enumerator.MoveNext
bool MoveNext()
Definition
ObjectCollection.cs:34
System.Net.Http.Headers.ObjectCollection.Enumerator
Definition
ObjectCollection.cs:12
source
System.Net.Http
System.Net.Http.Headers
ObjectCollection.cs
Generated by
1.10.0