Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OidCollection.cs
Go to the documentation of this file.
3
5
6public sealed class OidCollection : ICollection, IEnumerable
7{
8 private Oid[] _oids = Array.Empty<Oid>();
9
10 private int _count;
11
12 public Oid this[int index]
13 {
14 get
15 {
16 if ((uint)index >= (uint)_count)
17 {
18 throw new ArgumentOutOfRangeException("index");
19 }
20 return _oids[index];
21 }
22 }
23
24 public Oid? this[string oid]
25 {
26 get
27 {
28 string text = OidLookup.ToOid(oid, OidGroup.All, fallBackToAllGroups: false);
29 if (text == null)
30 {
31 text = oid;
32 }
33 for (int i = 0; i < _count; i++)
34 {
35 Oid oid2 = _oids[i];
36 if (oid2.Value == text)
37 {
38 return oid2;
39 }
40 }
41 return null;
42 }
43 }
44
45 public int Count => _count;
46
47 public bool IsSynchronized => false;
48
49 public object SyncRoot => this;
50
51 public int Add(Oid oid)
52 {
53 int count = _count;
54 if (count == _oids.Length)
55 {
56 Array.Resize(ref _oids, (count == 0) ? 4 : (count * 2));
57 }
58 _oids[count] = oid;
59 _count = count + 1;
60 return count;
61 }
62
64 {
65 return new OidEnumerator(this);
66 }
67
72
74 {
75 if (array == null)
76 {
77 throw new ArgumentNullException("array");
78 }
79 if (array.Rank != 1)
80 {
82 }
83 if (index < 0 || index >= array.Length)
84 {
86 }
87 if (index + Count > array.Length)
88 {
90 }
91 for (int i = 0; i < Count; i++)
92 {
93 array.SetValue(this[i], index);
94 index++;
95 }
96 }
97
98 public void CopyTo(Oid[] array, int index)
99 {
100 if (array == null)
101 {
102 throw new ArgumentNullException("array");
103 }
104 if (index < 0 || index >= array.Length)
105 {
107 }
109 }
110}
static string ToOid(string friendlyName, OidGroup oidGroup, bool fallBackToAllGroups)
Definition OidLookup.cs:39
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string Arg_RankMultiDimNotSupported
Definition SR.cs:18
static string Argument_InvalidOffLen
Definition SR.cs:22
Definition SR.cs:7
void CopyTo(Oid[] array, int index)
void CopyTo(Array array, int index)