Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SizedArray.cs
Go to the documentation of this file.
1
namespace
System.Runtime.Serialization.Formatters.Binary
;
2
3
internal
sealed
class
SizedArray
:
ICloneable
4
{
5
internal
object
[]
_objects
;
6
7
internal
object
[]
_negObjects
;
8
9
internal
object
this
[
int
index
]
10
{
11
get
12
{
13
if
(
index
< 0)
14
{
15
if
(-
index
<=
_negObjects
.Length - 1)
16
{
17
return
_negObjects
[-
index
];
18
}
19
return
null
;
20
}
21
if
(
index
<=
_objects
.Length - 1)
22
{
23
return
_objects
[
index
];
24
}
25
return
null
;
26
}
27
set
28
{
29
if
(
index
< 0)
30
{
31
if
(-
index
>
_negObjects
.Length - 1)
32
{
33
IncreaseCapacity
(
index
);
34
}
35
_negObjects
[-
index
] =
value
;
36
}
37
else
38
{
39
if
(
index
>
_objects
.Length - 1)
40
{
41
IncreaseCapacity
(
index
);
42
}
43
_objects
[
index
] =
value
;
44
}
45
}
46
}
47
48
internal
SizedArray
()
49
{
50
_objects
=
new
object
[16];
51
_negObjects
=
new
object
[4];
52
}
53
54
internal
SizedArray
(
int
length
)
55
{
56
_objects
=
new
object
[
length
];
57
_negObjects
=
new
object
[
length
];
58
}
59
60
private
SizedArray
(
SizedArray
sizedArray
)
61
{
62
_objects
=
new
object
[
sizedArray
._objects.Length];
63
sizedArray
._objects.CopyTo(
_objects
, 0);
64
_negObjects
=
new
object
[
sizedArray
._negObjects.Length];
65
sizedArray
._negObjects.CopyTo(
_negObjects
, 0);
66
}
67
68
public
object
Clone
()
69
{
70
return
new
SizedArray
(
this
);
71
}
72
73
internal
void
IncreaseCapacity
(
int
index
)
74
{
75
try
76
{
77
if
(
index
< 0)
78
{
79
int
num =
Math
.
Max
(
_negObjects
.Length * 2, -
index
+ 1);
80
object
[]
array
=
new
object
[num];
81
Array
.
Copy
(
_negObjects
,
array
,
_negObjects
.Length);
82
_negObjects
=
array
;
83
}
84
else
85
{
86
int
num2
=
Math
.
Max
(
_objects
.Length * 2,
index
+ 1);
87
object
[]
array2
=
new
object
[
num2
];
88
Array
.
Copy
(
_objects
,
array2
,
_objects
.Length);
89
_objects
=
array2
;
90
}
91
}
92
catch
(
Exception
)
93
{
94
throw
new
SerializationException
(
System
.
SR
.
Serialization_CorruptedStream
);
95
}
96
}
97
}
System.Array.Copy
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition
Array.cs:624
System.Array
Definition
Array.cs:16
System.Exception
Definition
Exception.cs:15
System.Math.Max
static byte Max(byte val1, byte val2)
Definition
Math.cs:738
System.Math
Definition
Math.cs:13
System.Runtime.Serialization.Formatters.Binary.SizedArray._objects
object[] _objects
Definition
SizedArray.cs:5
System.Runtime.Serialization.Formatters.Binary.SizedArray.SizedArray
SizedArray()
Definition
SizedArray.cs:48
System.Runtime.Serialization.Formatters.Binary.SizedArray.SizedArray
SizedArray(int length)
Definition
SizedArray.cs:54
System.Runtime.Serialization.Formatters.Binary.SizedArray.Clone
object Clone()
Definition
SizedArray.cs:68
System.Runtime.Serialization.Formatters.Binary.SizedArray.SizedArray
SizedArray(SizedArray sizedArray)
Definition
SizedArray.cs:60
System.Runtime.Serialization.Formatters.Binary.SizedArray.IncreaseCapacity
void IncreaseCapacity(int index)
Definition
SizedArray.cs:73
System.Runtime.Serialization.Formatters.Binary.SizedArray._negObjects
object[] _negObjects
Definition
SizedArray.cs:7
System.Runtime.Serialization.Formatters.Binary.SizedArray
Definition
SizedArray.cs:4
System.Runtime.Serialization.SerializationException
Definition
SerializationException.cs:8
System.SR.Serialization_CorruptedStream
static string Serialization_CorruptedStream
Definition
SR.cs:74
System.SR
Definition
SR.cs:7
System.ICloneable
Definition
ICloneable.cs:4
System.Runtime.Serialization.Formatters.Binary
Definition
BinaryArray.cs:1
System.Runtime.Serialization.CollectionKind.Dictionary
@ Dictionary
System.ExceptionArgument.value
@ value
System.ExceptionArgument.length
@ length
System.ExceptionArgument.index
@ index
System.ExceptionArgument.array
@ array
System
Definition
BlockingCollection.cs:8
source
System.Runtime.Serialization.Formatters
System.Runtime.Serialization.Formatters.Binary
SizedArray.cs
Generated by
1.10.0