Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlQuerySequence.cs
Go to the documentation of this file.
4
6
9{
10 public static readonly XmlQuerySequence<T> Empty = new XmlQuerySequence<T>();
11
12 private T[] _items;
13
14 private int _size;
15
16 public int Count => _size;
17
19
20 object ICollection.SyncRoot => this;
21
23
24 bool IList.IsFixedSize => true;
25
26 bool IList.IsReadOnly => true;
27
28 object IList.this[int index]
29 {
30 get
31 {
32 if (index >= _size)
33 {
34 throw new ArgumentOutOfRangeException("index");
35 }
36 return _items[index];
37 }
38 set
39 {
40 throw new NotSupportedException();
41 }
42 }
43
44 public T this[int index]
45 {
46 get
47 {
48 if (index >= _size)
49 {
50 throw new ArgumentOutOfRangeException("index");
51 }
52 return _items[index];
53 }
54 set
55 {
56 throw new NotSupportedException();
57 }
58 }
59
61 {
62 if (seq != null)
63 {
64 seq.Clear();
65 return seq;
66 }
67 return new XmlQuerySequence<T>();
68 }
69
71 {
72 if (seq != null)
73 {
74 seq.Clear();
75 seq.Add(item);
76 return seq;
77 }
78 return new XmlQuerySequence<T>(item);
79 }
80
82 {
83 _items = new T[16];
84 }
85
87 {
88 _items = new T[capacity];
89 }
90
91 public XmlQuerySequence(T[] array, int size)
92 {
93 _items = array;
94 _size = size;
95 }
96
98 {
99 _items = new T[1];
100 _items[0] = value;
101 _size = 1;
102 }
103
105 {
106 return new IListEnumerator<T>(this);
107 }
108
110 {
111 return new IListEnumerator<T>(this);
112 }
113
115 {
116 if (_size != 0)
117 {
119 }
120 }
121
123 {
124 throw new NotSupportedException();
125 }
126
128 {
129 throw new NotSupportedException();
130 }
131
132 public bool Contains(T value)
133 {
134 return IndexOf(value) != -1;
135 }
136
137 public void CopyTo(T[] array, int index)
138 {
139 for (int i = 0; i < Count; i++)
140 {
141 array[index + i] = this[i];
142 }
143 }
144
146 {
147 throw new NotSupportedException();
148 }
149
150 int IList.Add(object value)
151 {
152 throw new NotSupportedException();
153 }
154
156 {
157 throw new NotSupportedException();
158 }
159
160 bool IList.Contains(object value)
161 {
162 return Contains((T)value);
163 }
164
165 int IList.IndexOf(object value)
166 {
167 return IndexOf((T)value);
168 }
169
170 void IList.Insert(int index, object value)
171 {
172 throw new NotSupportedException();
173 }
174
175 void IList.Remove(object value)
176 {
177 throw new NotSupportedException();
178 }
179
181 {
182 throw new NotSupportedException();
183 }
184
185 public int IndexOf(T value)
186 {
187 int num = Array.IndexOf(_items, value);
188 if (num >= _size)
189 {
190 return -1;
191 }
192 return num;
193 }
194
195 void IList<T>.Insert(int index, T value)
196 {
197 throw new NotSupportedException();
198 }
199
200 void IList<T>.RemoveAt(int index)
201 {
202 throw new NotSupportedException();
203 }
204
205 public void Clear()
206 {
207 _size = 0;
209 }
210
211 public void Add(T value)
212 {
213 EnsureCache();
214 _items[_size++] = value;
216 }
217
218 public void SortByKeys(Array keys)
219 {
220 if (_size > 1)
221 {
222 Array.Sort(keys, _items, 0, _size);
224 }
225 }
226
227 private void EnsureCache()
228 {
229 if (_size >= _items.Length)
230 {
231 T[] array = new T[_size * 2];
232 CopyTo(array, 0);
233 _items = array;
234 }
235 }
236
237 protected virtual void OnItemsChanged()
238 {
239 }
240}
static void Sort(Array array)
Definition Array.cs:2329
int IList. IndexOf(object value)
Definition Array.cs:1228
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
void ICollection. CopyTo(Array array, int index)
static XmlQuerySequence< T > CreateOrReuse(XmlQuerySequence< T > seq)
static XmlQuerySequence< T > CreateOrReuse(XmlQuerySequence< T > seq, T item)
void CopyTo(T[] array, int arrayIndex)
new IEnumerator< T > GetEnumerator()
void Insert(int index, T item)