Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Array.cs
Go to the documentation of this file.
10
11namespace System;
12
14[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
16{
17 private static class EmptyArray<T>
18 {
19 internal static readonly T[] Value = new T[0];
20 }
21
22 private readonly struct SorterObjectArray
23 {
24 private readonly object[] keys;
25
26 private readonly object[] items;
27
28 private readonly IComparer comparer;
29
30 internal SorterObjectArray(object[] keys, object[] items, IComparer comparer)
31 {
32 this.keys = keys;
33 this.items = items;
34 this.comparer = comparer;
35 }
36
37 internal void SwapIfGreater(int a, int b)
38 {
39 if (a != b && comparer.Compare(keys[a], keys[b]) > 0)
40 {
41 object obj = keys[a];
42 keys[a] = keys[b];
43 keys[b] = obj;
44 if (items != null)
45 {
46 object obj2 = items[a];
47 items[a] = items[b];
48 items[b] = obj2;
49 }
50 }
51 }
52
53 private void Swap(int i, int j)
54 {
55 object obj = keys[i];
56 keys[i] = keys[j];
57 keys[j] = obj;
58 if (items != null)
59 {
60 object obj2 = items[i];
61 items[i] = items[j];
62 items[j] = obj2;
63 }
64 }
65
66 internal void Sort(int left, int length)
67 {
69 }
70
71 private void IntrospectiveSort(int left, int length)
72 {
73 if (length < 2)
74 {
75 return;
76 }
77 try
78 {
79 IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1));
80 }
82 {
84 }
85 catch (Exception e)
86 {
87 ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
88 }
89 }
90
91 private void IntroSort(int lo, int hi, int depthLimit)
92 {
93 while (hi > lo)
94 {
95 int num = hi - lo + 1;
96 if (num <= 16)
97 {
98 switch (num)
99 {
100 case 2:
101 SwapIfGreater(lo, hi);
102 break;
103 case 3:
104 SwapIfGreater(lo, hi - 1);
105 SwapIfGreater(lo, hi);
106 SwapIfGreater(hi - 1, hi);
107 break;
108 default:
109 InsertionSort(lo, hi);
110 break;
111 }
112 break;
113 }
114 if (depthLimit == 0)
115 {
116 Heapsort(lo, hi);
117 break;
118 }
119 depthLimit--;
120 int num2 = PickPivotAndPartition(lo, hi);
122 hi = num2 - 1;
123 }
124 }
125
126 private int PickPivotAndPartition(int lo, int hi)
127 {
128 int num = lo + (hi - lo) / 2;
129 SwapIfGreater(lo, num);
130 SwapIfGreater(lo, hi);
131 SwapIfGreater(num, hi);
132 object obj = keys[num];
133 Swap(num, hi - 1);
134 int num2 = lo;
135 int num3 = hi - 1;
136 while (num2 < num3)
137 {
138 while (comparer.Compare(keys[++num2], obj) < 0)
139 {
140 }
141 while (comparer.Compare(obj, keys[--num3]) < 0)
142 {
143 }
144 if (num2 >= num3)
145 {
146 break;
147 }
148 Swap(num2, num3);
149 }
150 if (num2 != hi - 1)
151 {
152 Swap(num2, hi - 1);
153 }
154 return num2;
155 }
156
157 private void Heapsort(int lo, int hi)
158 {
159 int num = hi - lo + 1;
160 for (int num2 = num / 2; num2 >= 1; num2--)
161 {
162 DownHeap(num2, num, lo);
163 }
164 for (int num3 = num; num3 > 1; num3--)
165 {
166 Swap(lo, lo + num3 - 1);
167 DownHeap(1, num3 - 1, lo);
168 }
169 }
170
171 private void DownHeap(int i, int n, int lo)
172 {
173 object obj = keys[lo + i - 1];
174 object[] array = items;
175 object obj2 = ((array != null) ? array[lo + i - 1] : null);
176 while (i <= n / 2)
177 {
178 int num = 2 * i;
179 if (num < n && comparer.Compare(keys[lo + num - 1], keys[lo + num]) < 0)
180 {
181 num++;
182 }
183 if (comparer.Compare(obj, keys[lo + num - 1]) >= 0)
184 {
185 break;
186 }
187 keys[lo + i - 1] = keys[lo + num - 1];
188 if (items != null)
189 {
190 items[lo + i - 1] = items[lo + num - 1];
191 }
192 i = num;
193 }
194 keys[lo + i - 1] = obj;
195 if (items != null)
196 {
197 items[lo + i - 1] = obj2;
198 }
199 }
200
201 private void InsertionSort(int lo, int hi)
202 {
203 for (int i = lo; i < hi; i++)
204 {
205 int num = i;
206 object obj = keys[i + 1];
207 object[] array = items;
208 object obj2 = ((array != null) ? array[i + 1] : null);
209 while (num >= lo && comparer.Compare(obj, keys[num]) < 0)
210 {
211 keys[num + 1] = keys[num];
212 if (items != null)
213 {
214 items[num + 1] = items[num];
215 }
216 num--;
217 }
218 keys[num + 1] = obj;
219 if (items != null)
220 {
221 items[num + 1] = obj2;
222 }
223 }
224 }
225 }
226
227 private readonly struct SorterGenericArray
228 {
229 private readonly Array keys;
230
231 private readonly Array items;
232
233 private readonly IComparer comparer;
234
236 {
237 this.keys = keys;
238 this.items = items;
239 this.comparer = comparer;
240 }
241
242 internal void SwapIfGreater(int a, int b)
243 {
244 if (a != b && comparer.Compare(keys.GetValue(a), keys.GetValue(b)) > 0)
245 {
246 object value = keys.GetValue(a);
249 if (items != null)
250 {
251 object value2 = items.GetValue(a);
254 }
255 }
256 }
257
258 private void Swap(int i, int j)
259 {
260 object value = keys.GetValue(i);
263 if (items != null)
264 {
265 object value2 = items.GetValue(i);
268 }
269 }
270
271 internal void Sort(int left, int length)
272 {
274 }
275
276 private void IntrospectiveSort(int left, int length)
277 {
278 if (length < 2)
279 {
280 return;
281 }
282 try
283 {
284 IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1));
285 }
287 {
289 }
290 catch (Exception e)
291 {
292 ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
293 }
294 }
295
296 private void IntroSort(int lo, int hi, int depthLimit)
297 {
298 while (hi > lo)
299 {
300 int num = hi - lo + 1;
301 if (num <= 16)
302 {
303 switch (num)
304 {
305 case 2:
306 SwapIfGreater(lo, hi);
307 break;
308 case 3:
309 SwapIfGreater(lo, hi - 1);
310 SwapIfGreater(lo, hi);
311 SwapIfGreater(hi - 1, hi);
312 break;
313 default:
314 InsertionSort(lo, hi);
315 break;
316 }
317 break;
318 }
319 if (depthLimit == 0)
320 {
321 Heapsort(lo, hi);
322 break;
323 }
324 depthLimit--;
325 int num2 = PickPivotAndPartition(lo, hi);
327 hi = num2 - 1;
328 }
329 }
330
331 private int PickPivotAndPartition(int lo, int hi)
332 {
333 int num = lo + (hi - lo) / 2;
334 SwapIfGreater(lo, num);
335 SwapIfGreater(lo, hi);
336 SwapIfGreater(num, hi);
337 object value = keys.GetValue(num);
338 Swap(num, hi - 1);
339 int num2 = lo;
340 int num3 = hi - 1;
341 while (num2 < num3)
342 {
343 while (comparer.Compare(keys.GetValue(++num2), value) < 0)
344 {
345 }
346 while (comparer.Compare(value, keys.GetValue(--num3)) < 0)
347 {
348 }
349 if (num2 >= num3)
350 {
351 break;
352 }
353 Swap(num2, num3);
354 }
355 if (num2 != hi - 1)
356 {
357 Swap(num2, hi - 1);
358 }
359 return num2;
360 }
361
362 private void Heapsort(int lo, int hi)
363 {
364 int num = hi - lo + 1;
365 for (int num2 = num / 2; num2 >= 1; num2--)
366 {
367 DownHeap(num2, num, lo);
368 }
369 for (int num3 = num; num3 > 1; num3--)
370 {
371 Swap(lo, lo + num3 - 1);
372 DownHeap(1, num3 - 1, lo);
373 }
374 }
375
376 private void DownHeap(int i, int n, int lo)
377 {
378 object value = keys.GetValue(lo + i - 1);
379 object value2 = items?.GetValue(lo + i - 1);
380 while (i <= n / 2)
381 {
382 int num = 2 * i;
383 if (num < n && comparer.Compare(keys.GetValue(lo + num - 1), keys.GetValue(lo + num)) < 0)
384 {
385 num++;
386 }
387 if (comparer.Compare(value, keys.GetValue(lo + num - 1)) >= 0)
388 {
389 break;
390 }
391 keys.SetValue(keys.GetValue(lo + num - 1), lo + i - 1);
392 if (items != null)
393 {
394 items.SetValue(items.GetValue(lo + num - 1), lo + i - 1);
395 }
396 i = num;
397 }
398 keys.SetValue(value, lo + i - 1);
399 if (items != null)
400 {
401 items.SetValue(value2, lo + i - 1);
402 }
403 }
404
405 private void InsertionSort(int lo, int hi)
406 {
407 for (int i = lo; i < hi; i++)
408 {
409 int num = i;
410 object value = keys.GetValue(i + 1);
411 object value2 = items?.GetValue(i + 1);
412 while (num >= lo && comparer.Compare(value, keys.GetValue(num)) < 0)
413 {
414 keys.SetValue(keys.GetValue(num), num + 1);
415 if (items != null)
416 {
417 items.SetValue(items.GetValue(num), num + 1);
418 }
419 num--;
420 }
421 keys.SetValue(value, num + 1);
422 if (items != null)
423 {
424 items.SetValue(value2, num + 1);
425 }
426 }
427 }
428 }
429
430 public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length);
431
432 internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length;
433
434 public long LongLength => (long)NativeLength;
435
436 public int Rank
437 {
438 get
439 {
442 {
443 return 1;
444 }
446 }
447 }
448
449 int ICollection.Count => Length;
450
451 public object SyncRoot => this;
452
453 public bool IsReadOnly => false;
454
455 public bool IsFixedSize => true;
456
457 public bool IsSynchronized => false;
458
459 object? IList.this[int index]
460 {
461 get
462 {
463 return GetValue(index);
464 }
465 set
466 {
468 }
469 }
470
471 public static int MaxLength => 2147483591;
472
473 public unsafe static Array CreateInstance(Type elementType, int length)
474 {
475 if ((object)elementType == null)
476 {
478 }
479 if (length < 0)
480 {
482 }
483 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
484 if (runtimeType == null)
485 {
487 }
488 return InternalCreate((void*)runtimeType.TypeHandle.Value, 1, &length, null);
489 }
490
491 public unsafe static Array CreateInstance(Type elementType, int length1, int length2)
492 {
493 if ((object)elementType == null)
494 {
496 }
497 if (length1 < 0)
498 {
499 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
500 }
501 if (length2 < 0)
502 {
503 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
504 }
505 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
506 if (runtimeType == null)
507 {
509 }
510 int* ptr = stackalloc int[2];
511 *ptr = length1;
512 ptr[1] = length2;
513 return InternalCreate((void*)runtimeType.TypeHandle.Value, 2, ptr, null);
514 }
515
516 public unsafe static Array CreateInstance(Type elementType, int length1, int length2, int length3)
517 {
518 if ((object)elementType == null)
519 {
521 }
522 if (length1 < 0)
523 {
524 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
525 }
526 if (length2 < 0)
527 {
528 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
529 }
530 if (length3 < 0)
531 {
532 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length3, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
533 }
534 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
535 if (runtimeType == null)
536 {
538 }
539 int* ptr = stackalloc int[3];
540 *ptr = length1;
541 ptr[1] = length2;
542 ptr[2] = length3;
543 return InternalCreate((void*)runtimeType.TypeHandle.Value, 3, ptr, null);
544 }
545
546 public unsafe static Array CreateInstance(Type elementType, params int[] lengths)
547 {
548 if ((object)elementType == null)
549 {
551 }
552 if (lengths == null)
553 {
555 }
556 if (lengths.Length == 0)
557 {
559 }
560 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
561 if (runtimeType == null)
562 {
564 }
565 for (int i = 0; i < lengths.Length; i++)
566 {
567 if (lengths[i] < 0)
568 {
569 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
570 }
571 }
572 fixed (int* pLengths = &lengths[0])
573 {
574 return InternalCreate((void*)runtimeType.TypeHandle.Value, lengths.Length, pLengths, null);
575 }
576 }
577
578 public unsafe static Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds)
579 {
580 if (elementType == null)
581 {
583 }
584 if (lengths == null)
585 {
587 }
588 if (lowerBounds == null)
589 {
591 }
592 if (lengths.Length != lowerBounds.Length)
593 {
595 }
596 if (lengths.Length == 0)
597 {
599 }
600 RuntimeType runtimeType = elementType.UnderlyingSystemType as RuntimeType;
601 if (runtimeType == null)
602 {
604 }
605 for (int i = 0; i < lengths.Length; i++)
606 {
607 if (lengths[i] < 0)
608 {
609 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
610 }
611 }
612 fixed (int* pLengths = &lengths[0])
613 {
614 fixed (int* pLowerBounds = &lowerBounds[0])
615 {
616 return InternalCreate((void*)runtimeType.TypeHandle.Value, lengths.Length, pLengths, pLowerBounds);
617 }
618 }
619 }
620
621 [MethodImpl(MethodImplOptions.InternalCall)]
622 private unsafe static extern Array InternalCreate(void* elementType, int rank, int* pLengths, int* pLowerBounds);
623
624 public unsafe static void Copy(Array sourceArray, Array destinationArray, int length)
625 {
626 if (sourceArray == null)
627 {
629 }
630 if (destinationArray == null)
631 {
633 }
635 if (methodTable == RuntimeHelpers.GetMethodTable(destinationArray) && !methodTable->IsMultiDimensionalArray && (uint)length <= sourceArray.NativeLength && (uint)length <= destinationArray.NativeLength)
636 {
637 nuint num = (nuint)(uint)length * (nuint)methodTable->ComponentSize;
638 ref byte data = ref Unsafe.As<RawArrayData>(sourceArray).Data;
639 ref byte data2 = ref Unsafe.As<RawArrayData>(destinationArray).Data;
640 if (methodTable->ContainsGCPointers)
641 {
642 Buffer.BulkMoveWithWriteBarrier(ref data2, ref data, num);
643 }
644 else
645 {
646 Buffer.Memmove(ref data2, ref data, num);
647 }
648 }
649 else
650 {
651 Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, reliable: false);
652 }
653 }
654
656 {
657 if (sourceArray != null && destinationArray != null)
658 {
660 if (methodTable == RuntimeHelpers.GetMethodTable(destinationArray) && !methodTable->IsMultiDimensionalArray && length >= 0 && sourceIndex >= 0 && destinationIndex >= 0 && (uint)(sourceIndex + length) <= sourceArray.NativeLength && (uint)(destinationIndex + length) <= destinationArray.NativeLength)
661 {
662 nuint num = methodTable->ComponentSize;
663 nuint num2 = (uint)length * num;
664 ref byte reference = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * num);
665 ref byte reference2 = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * num);
666 if (methodTable->ContainsGCPointers)
667 {
669 }
670 else
671 {
673 }
674 return;
675 }
676 }
678 }
679
680 private unsafe static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable)
681 {
682 if (sourceArray == null)
683 {
685 }
686 if (destinationArray == null)
687 {
689 }
690 if (sourceArray.GetType() != destinationArray.GetType() && sourceArray.Rank != destinationArray.Rank)
691 {
693 }
694 if (length < 0)
695 {
697 }
698 int lowerBound = sourceArray.GetLowerBound(0);
700 {
702 }
704 int lowerBound2 = destinationArray.GetLowerBound(0);
706 {
707 throw new ArgumentOutOfRangeException("destinationIndex", SR.ArgumentOutOfRange_ArrayLB);
708 }
710 if ((uint)(sourceIndex + length) > sourceArray.NativeLength)
711 {
712 throw new ArgumentException(SR.Arg_LongerThanSrcArray, "sourceArray");
713 }
714 if ((uint)(destinationIndex + length) > destinationArray.NativeLength)
715 {
716 throw new ArgumentException(SR.Arg_LongerThanDestArray, "destinationArray");
717 }
719 {
721 nuint num = methodTable->ComponentSize;
722 nuint num2 = (uint)length * num;
725 if (methodTable->ContainsGCPointers)
726 {
728 }
729 else
730 {
732 }
733 }
734 else
735 {
736 if (reliable)
737 {
739 }
741 }
742 }
743
744 [MethodImpl(MethodImplOptions.InternalCall)]
746
747 [MethodImpl(MethodImplOptions.InternalCall)]
749
754
755 public unsafe static void Clear(Array array)
756 {
757 if (array == null)
758 {
760 }
762 nuint num = methodTable->ComponentSize * array.NativeLength;
764 if (!methodTable->ContainsGCPointers)
765 {
767 }
768 else
769 {
771 }
772 }
773
774 public unsafe static void Clear(Array array, int index, int length)
775 {
776 if (array == null)
777 {
779 }
780 ref byte source = ref Unsafe.As<RawArrayData>(array).Data;
781 int num = 0;
783 if (methodTable->IsMultiDimensionalArray)
784 {
785 int multiDimensionalArrayRank = methodTable->MultiDimensionalArrayRank;
786 num = Unsafe.Add(ref Unsafe.As<byte, int>(ref source), multiDimensionalArrayRank);
788 }
789 int num2 = index - num;
790 if (index < num || num2 < 0 || length < 0 || (uint)(num2 + length) > array.NativeLength)
791 {
793 }
794 nuint num3 = methodTable->ComponentSize;
795 ref byte reference = ref Unsafe.AddByteOffset(ref source, (uint)num2 * num3);
796 nuint num4 = (uint)length * num3;
797 if (methodTable->ContainsGCPointers)
798 {
800 }
801 else
802 {
804 }
805 }
806
808 {
809 if (RuntimeHelpers.GetMethodTable(this)->IsMultiDimensionalArray)
810 {
812 nint num = 0;
813 for (int i = 0; i < indices.Length; i++)
814 {
815 int num2 = indices[i] - Unsafe.Add(ref multiDimensionalArrayBounds, indices.Length + i);
817 if ((uint)num2 >= (uint)num3)
818 {
820 }
821 num = num3 * num + num2;
822 }
823 return num;
824 }
825 int num4 = indices[0];
826 if ((uint)num4 >= (uint)LongLength)
827 {
829 }
830 return num4;
831 }
832
833 [MethodImpl(MethodImplOptions.InternalCall)]
834 internal extern object InternalGetValue(nint flattenedIndex);
835
836 [MethodImpl(MethodImplOptions.InternalCall)]
837 private extern void InternalSetValue(object value, nint flattenedIndex);
838
852
867
881
882 [MethodImpl(MethodImplOptions.InternalCall)]
884
885 private unsafe bool IsValueOfElementType(object value)
886 {
889 }
890
891 [MethodImpl(MethodImplOptions.InternalCall)]
892 public extern void Initialize();
893
894 private protected Array()
895 {
896 }
897
899 {
900 if (array == null)
901 {
903 }
904 return new ReadOnlyCollection<T>(array);
905 }
906
907 public static void Resize<T>([NotNull] ref T[]? array, int newSize)
908 {
909 if (newSize < 0)
910 {
911 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.newSize, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
912 }
913 T[] array2 = array;
914 if (array2 == null)
915 {
916 array = new T[newSize];
917 }
918 else if (array2.Length != newSize)
919 {
920 T[] array3 = new T[newSize];
922 array = array3;
923 }
924 }
925
927 {
928 if (lengths == null)
929 {
931 }
932 if (lengths.Length == 0)
933 {
935 }
936 int[] array = new int[lengths.Length];
937 for (int i = 0; i < lengths.Length; i++)
938 {
939 long num = lengths[i];
940 int num2 = (int)num;
941 if (num != num2)
942 {
943 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.len, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
944 }
945 array[i] = num2;
946 }
948 }
949
951 {
952 int num = (int)length;
953 if (length != num)
954 {
955 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
956 }
958 }
959
961 {
962 int num = (int)sourceIndex;
963 int num2 = (int)destinationIndex;
964 int num3 = (int)length;
965 if (sourceIndex != num)
966 {
967 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.sourceIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
968 }
969 if (destinationIndex != num2)
970 {
971 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.destinationIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
972 }
973 if (length != num3)
974 {
975 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
976 }
978 }
979
980 public object? GetValue(params int[] indices)
981 {
982 if (indices == null)
983 {
985 }
986 if (Rank != indices.Length)
987 {
989 }
991 }
992
993 public unsafe object? GetValue(int index)
994 {
995 if (Rank != 1)
996 {
998 }
1000 }
1001
1002 public object? GetValue(int index1, int index2)
1003 {
1004 if (Rank != 2)
1005 {
1007 }
1008 Span<int> span = stackalloc int[2] { index1, index2 };
1010 }
1011
1012 public object? GetValue(int index1, int index2, int index3)
1013 {
1014 if (Rank != 3)
1015 {
1017 }
1020 }
1021
1022 public unsafe void SetValue(object? value, int index)
1023 {
1024 if (Rank != 1)
1025 {
1027 }
1029 }
1030
1031 public void SetValue(object? value, int index1, int index2)
1032 {
1033 if (Rank != 2)
1034 {
1036 }
1037 Span<int> span = stackalloc int[2] { index1, index2 };
1039 }
1040
1041 public void SetValue(object? value, int index1, int index2, int index3)
1042 {
1043 if (Rank != 3)
1044 {
1046 }
1049 }
1050
1051 public void SetValue(object? value, params int[] indices)
1052 {
1053 if (indices == null)
1054 {
1056 }
1057 if (Rank != indices.Length)
1058 {
1060 }
1062 }
1063
1064 public object? GetValue(long index)
1065 {
1066 int num = (int)index;
1067 if (index != num)
1068 {
1069 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1070 }
1071 return GetValue(num);
1072 }
1073
1074 public object? GetValue(long index1, long index2)
1075 {
1076 int num = (int)index1;
1077 int num2 = (int)index2;
1078 if (index1 != num)
1079 {
1080 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1081 }
1082 if (index2 != num2)
1083 {
1084 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1085 }
1086 return GetValue(num, num2);
1087 }
1088
1089 public object? GetValue(long index1, long index2, long index3)
1090 {
1091 int num = (int)index1;
1092 int num2 = (int)index2;
1093 int num3 = (int)index3;
1094 if (index1 != num)
1095 {
1096 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1097 }
1098 if (index2 != num2)
1099 {
1100 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1101 }
1102 if (index3 != num3)
1103 {
1104 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1105 }
1106 return GetValue(num, num2, num3);
1107 }
1108
1109 public object? GetValue(params long[] indices)
1110 {
1111 if (indices == null)
1112 {
1114 }
1115 if (Rank != indices.Length)
1116 {
1118 }
1119 int[] array = new int[indices.Length];
1120 for (int i = 0; i < indices.Length; i++)
1121 {
1122 long num = indices[i];
1123 int num2 = (int)num;
1124 if (num != num2)
1125 {
1126 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1127 }
1128 array[i] = num2;
1129 }
1130 return GetValue(array);
1131 }
1132
1133 public void SetValue(object? value, long index)
1134 {
1135 int num = (int)index;
1136 if (index != num)
1137 {
1138 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1139 }
1140 SetValue(value, num);
1141 }
1142
1143 public void SetValue(object? value, long index1, long index2)
1144 {
1145 int num = (int)index1;
1146 int num2 = (int)index2;
1147 if (index1 != num)
1148 {
1149 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1150 }
1151 if (index2 != num2)
1152 {
1153 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1154 }
1155 SetValue(value, num, num2);
1156 }
1157
1158 public void SetValue(object? value, long index1, long index2, long index3)
1159 {
1160 int num = (int)index1;
1161 int num2 = (int)index2;
1162 int num3 = (int)index3;
1163 if (index1 != num)
1164 {
1165 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1166 }
1167 if (index2 != num2)
1168 {
1169 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1170 }
1171 if (index3 != num3)
1172 {
1173 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1174 }
1175 SetValue(value, num, num2, num3);
1176 }
1177
1178 public void SetValue(object? value, params long[] indices)
1179 {
1180 if (indices == null)
1181 {
1183 }
1184 if (Rank != indices.Length)
1185 {
1187 }
1188 int[] array = new int[indices.Length];
1189 for (int i = 0; i < indices.Length; i++)
1190 {
1191 long num = indices[i];
1192 int num2 = (int)num;
1193 if (num != num2)
1194 {
1195 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1196 }
1197 array[i] = num2;
1198 }
1200 }
1201
1202 private static int GetMedian(int low, int hi)
1203 {
1204 return low + (hi - low >> 1);
1205 }
1206
1207 public long GetLongLength(int dimension)
1208 {
1209 return GetLength(dimension);
1210 }
1211
1212 int IList.Add(object value)
1213 {
1214 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
1215 return 0;
1216 }
1217
1218 bool IList.Contains(object value)
1219 {
1220 return IndexOf(this, value) >= GetLowerBound(0);
1221 }
1222
1224 {
1225 Clear(this);
1226 }
1227
1228 int IList.IndexOf(object value)
1229 {
1230 return IndexOf(this, value);
1231 }
1232
1233 void IList.Insert(int index, object value)
1234 {
1235 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
1236 }
1237
1238 void IList.Remove(object value)
1239 {
1240 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
1241 }
1242
1244 {
1245 ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
1246 }
1247
1248 [Intrinsic]
1249 public object Clone()
1250 {
1251 return MemberwiseClone();
1252 }
1253
1255 {
1256 if (other == null)
1257 {
1258 return 1;
1259 }
1261 if (array == null || Length != array.Length)
1262 {
1263 ThrowHelper.ThrowArgumentException(ExceptionResource.ArgumentException_OtherNotArrayOfCorrectLength, ExceptionArgument.other);
1264 }
1265 int i = 0;
1266 int num = 0;
1267 for (; i < array.Length; i++)
1268 {
1269 if (num != 0)
1270 {
1271 break;
1272 }
1273 object value = GetValue(i);
1274 object value2 = array.GetValue(i);
1275 num = comparer.Compare(value, value2);
1276 }
1277 return num;
1278 }
1279
1281 {
1282 if (other == null)
1283 {
1284 return false;
1285 }
1286 if (this == other)
1287 {
1288 return true;
1289 }
1290 if (!(other is Array array) || array.Length != Length)
1291 {
1292 return false;
1293 }
1294 for (int i = 0; i < array.Length; i++)
1295 {
1296 object value = GetValue(i);
1297 object value2 = array.GetValue(i);
1298 if (!comparer.Equals(value, value2))
1299 {
1300 return false;
1301 }
1302 }
1303 return true;
1304 }
1305
1307 {
1308 if (comparer == null)
1309 {
1311 }
1312 HashCode hashCode = default(HashCode);
1313 for (int i = ((Length >= 8) ? (Length - 8) : 0); i < Length; i++)
1314 {
1315 hashCode.Add(comparer.GetHashCode(GetValue(i)));
1316 }
1317 return hashCode.ToHashCode();
1318 }
1319
1320 public static int BinarySearch(Array array, object? value)
1321 {
1322 if (array == null)
1323 {
1325 }
1326 return BinarySearch(array, array.GetLowerBound(0), array.Length, value, null);
1327 }
1328
1329 public static int BinarySearch(Array array, int index, int length, object? value)
1330 {
1331 return BinarySearch(array, index, length, value, null);
1332 }
1333
1334 public static int BinarySearch(Array array, object? value, IComparer? comparer)
1335 {
1336 if (array == null)
1337 {
1339 }
1340 return BinarySearch(array, array.GetLowerBound(0), array.Length, value, comparer);
1341 }
1342
1343 public static int BinarySearch(Array array, int index, int length, object? value, IComparer? comparer)
1344 {
1345 if (array == null)
1346 {
1348 }
1349 int lowerBound = array.GetLowerBound(0);
1350 if (index < lowerBound)
1351 {
1353 }
1354 if (length < 0)
1355 {
1357 }
1358 if (array.Length - (index - lowerBound) < length)
1359 {
1361 }
1362 if (array.Rank != 1)
1363 {
1364 ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
1365 }
1366 if (comparer == null)
1367 {
1369 }
1370 int num = index;
1371 int num2 = index + length - 1;
1372 if (array is object[] array2)
1373 {
1374 while (num <= num2)
1375 {
1376 int median = GetMedian(num, num2);
1377 int num3;
1378 try
1379 {
1380 num3 = comparer.Compare(array2[median], value);
1381 }
1382 catch (Exception e)
1383 {
1384 ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
1385 return 0;
1386 }
1387 if (num3 == 0)
1388 {
1389 return median;
1390 }
1391 if (num3 < 0)
1392 {
1393 num = median + 1;
1394 }
1395 else
1396 {
1397 num2 = median - 1;
1398 }
1399 }
1400 return ~num;
1401 }
1402 if (comparer == Comparer.Default)
1403 {
1404 CorElementType corElementTypeOfElementType = array.GetCorElementTypeOfElementType();
1405 if (corElementTypeOfElementType.IsPrimitiveType())
1406 {
1407 if (value == null)
1408 {
1409 return ~index;
1410 }
1411 if (array.IsValueOfElementType(value))
1412 {
1414 int num4 = -1;
1416 {
1417 case CorElementType.ELEMENT_TYPE_I1:
1419 break;
1420 case CorElementType.ELEMENT_TYPE_BOOLEAN:
1421 case CorElementType.ELEMENT_TYPE_U1:
1423 break;
1424 case CorElementType.ELEMENT_TYPE_I2:
1426 break;
1427 case CorElementType.ELEMENT_TYPE_CHAR:
1428 case CorElementType.ELEMENT_TYPE_U2:
1430 break;
1431 case CorElementType.ELEMENT_TYPE_I4:
1433 break;
1434 case CorElementType.ELEMENT_TYPE_U4:
1436 break;
1437 case CorElementType.ELEMENT_TYPE_I8:
1438 case CorElementType.ELEMENT_TYPE_I:
1440 break;
1441 case CorElementType.ELEMENT_TYPE_U8:
1442 case CorElementType.ELEMENT_TYPE_U:
1444 break;
1445 case CorElementType.ELEMENT_TYPE_R4:
1447 break;
1448 case CorElementType.ELEMENT_TYPE_R8:
1450 break;
1451 }
1452 if (num4 < 0)
1453 {
1454 return ~(index + ~num4);
1455 }
1456 return index + num4;
1457 }
1458 }
1459 }
1460 while (num <= num2)
1461 {
1462 int median2 = GetMedian(num, num2);
1463 int num5;
1464 try
1465 {
1466 num5 = comparer.Compare(array.GetValue(median2), value);
1467 }
1468 catch (Exception e2)
1469 {
1470 ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e2);
1471 return 0;
1472 }
1473 if (num5 == 0)
1474 {
1475 return median2;
1476 }
1477 if (num5 < 0)
1478 {
1479 num = median2 + 1;
1480 }
1481 else
1482 {
1483 num2 = median2 - 1;
1484 }
1485 }
1486 return ~num;
1487 static int GenericBinarySearch<T>(Array array, int adjustedIndex, int length, object value) where T : struct, IComparable<T>
1488 {
1489 return UnsafeArrayAsSpan<T>(array, adjustedIndex, length).BinarySearch(Unsafe.As<byte, T>(ref value.GetRawData()));
1490 }
1491 }
1492
1493 public static int BinarySearch<T>(T[] array, T value)
1494 {
1495 if (array == null)
1496 {
1498 }
1499 return BinarySearch(array, 0, array.Length, value, null);
1500 }
1501
1503 {
1504 if (array == null)
1505 {
1507 }
1508 return BinarySearch(array, 0, array.Length, value, comparer);
1509 }
1510
1511 public static int BinarySearch<T>(T[] array, int index, int length, T value)
1512 {
1513 return BinarySearch(array, index, length, value, null);
1514 }
1515
1516 public static int BinarySearch<T>(T[] array, int index, int length, T value, IComparer<T>? comparer)
1517 {
1518 if (array == null)
1519 {
1521 }
1522 if (index < 0)
1523 {
1525 }
1526 if (length < 0)
1527 {
1529 }
1530 if (array.Length - index < length)
1531 {
1533 }
1534 return ArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer);
1535 }
1536
1538 {
1539 if (array == null)
1540 {
1542 }
1543 if (converter == null)
1544 {
1546 }
1547 TOutput[] array2 = new TOutput[array.Length];
1548 for (int i = 0; i < array.Length; i++)
1549 {
1550 array2[i] = converter(array[i]);
1551 }
1552 return array2;
1553 }
1554
1555 public void CopyTo(Array array, int index)
1556 {
1557 if (array != null && array.Rank != 1)
1558 {
1559 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
1560 }
1561 Copy(this, GetLowerBound(0), array, index, Length);
1562 }
1563
1564 public void CopyTo(Array array, long index)
1565 {
1566 int num = (int)index;
1567 if (index != num)
1568 {
1569 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported);
1570 }
1571 CopyTo(array, num);
1572 }
1573
1574 public static T[] Empty<T>()
1575 {
1576 return EmptyArray<T>.Value;
1577 }
1578
1579 public static bool Exists<T>(T[] array, Predicate<T> match)
1580 {
1581 return FindIndex(array, match) != -1;
1582 }
1583
1584 public static void Fill<T>(T[] array, T value)
1585 {
1586 if (array == null)
1587 {
1589 }
1590 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
1591 {
1592 for (int i = 0; i < array.Length; i++)
1593 {
1594 array[i] = value;
1595 }
1596 }
1597 else
1598 {
1599 new Span<T>(array).Fill(value);
1600 }
1601 }
1602
1603 public static void Fill<T>(T[] array, T value, int startIndex, int count)
1604 {
1605 if (array == null)
1606 {
1608 }
1609 if ((uint)startIndex > (uint)array.Length)
1610 {
1612 }
1613 if ((uint)count > (uint)(array.Length - startIndex))
1614 {
1616 }
1617 if (!typeof(T).IsValueType && array.GetType() != typeof(T[]))
1618 {
1619 for (int i = startIndex; i < startIndex + count; i++)
1620 {
1621 array[i] = value;
1622 }
1623 }
1624 else
1625 {
1627 }
1628 }
1629
1630 public static T? Find<T>(T[] array, Predicate<T> match)
1631 {
1632 if (array == null)
1633 {
1635 }
1636 if (match == null)
1637 {
1639 }
1640 for (int i = 0; i < array.Length; i++)
1641 {
1642 if (match(array[i]))
1643 {
1644 return array[i];
1645 }
1646 }
1647 return default(T);
1648 }
1649
1650 public static T[] FindAll<T>(T[] array, Predicate<T> match)
1651 {
1652 if (array == null)
1653 {
1655 }
1656 if (match == null)
1657 {
1659 }
1660 List<T> list = new List<T>();
1661 for (int i = 0; i < array.Length; i++)
1662 {
1663 if (match(array[i]))
1664 {
1665 list.Add(array[i]);
1666 }
1667 }
1668 return list.ToArray();
1669 }
1670
1671 public static int FindIndex<T>(T[] array, Predicate<T> match)
1672 {
1673 if (array == null)
1674 {
1676 }
1677 return FindIndex(array, 0, array.Length, match);
1678 }
1679
1680 public static int FindIndex<T>(T[] array, int startIndex, Predicate<T> match)
1681 {
1682 if (array == null)
1683 {
1685 }
1686 return FindIndex(array, startIndex, array.Length - startIndex, match);
1687 }
1688
1689 public static int FindIndex<T>(T[] array, int startIndex, int count, Predicate<T> match)
1690 {
1691 if (array == null)
1692 {
1694 }
1696 {
1698 }
1700 {
1702 }
1703 if (match == null)
1704 {
1706 }
1707 int num = startIndex + count;
1708 for (int i = startIndex; i < num; i++)
1709 {
1710 if (match(array[i]))
1711 {
1712 return i;
1713 }
1714 }
1715 return -1;
1716 }
1717
1718 public static T? FindLast<T>(T[] array, Predicate<T> match)
1719 {
1720 if (array == null)
1721 {
1723 }
1724 if (match == null)
1725 {
1727 }
1728 for (int num = array.Length - 1; num >= 0; num--)
1729 {
1730 if (match(array[num]))
1731 {
1732 return array[num];
1733 }
1734 }
1735 return default(T);
1736 }
1737
1739 {
1740 if (array == null)
1741 {
1743 }
1744 return FindLastIndex(array, array.Length - 1, array.Length, match);
1745 }
1746
1748 {
1749 if (array == null)
1750 {
1752 }
1753 return FindLastIndex(array, startIndex, startIndex + 1, match);
1754 }
1755
1756 public static int FindLastIndex<T>(T[] array, int startIndex, int count, Predicate<T> match)
1757 {
1758 if (array == null)
1759 {
1761 }
1762 if (match == null)
1763 {
1765 }
1766 if (array.Length == 0)
1767 {
1768 if (startIndex != -1)
1769 {
1771 }
1772 }
1773 else if (startIndex < 0 || startIndex >= array.Length)
1774 {
1776 }
1777 if (count < 0 || startIndex - count + 1 < 0)
1778 {
1780 }
1781 int num = startIndex - count;
1782 for (int num2 = startIndex; num2 > num; num2--)
1783 {
1784 if (match(array[num2]))
1785 {
1786 return num2;
1787 }
1788 }
1789 return -1;
1790 }
1791
1792 public static void ForEach<T>(T[] array, Action<T> action)
1793 {
1794 if (array == null)
1795 {
1797 }
1798 if (action == null)
1799 {
1801 }
1802 for (int i = 0; i < array.Length; i++)
1803 {
1804 action(array[i]);
1805 }
1806 }
1807
1808 public static int IndexOf(Array array, object? value)
1809 {
1810 if (array == null)
1811 {
1813 }
1814 return IndexOf(array, value, array.GetLowerBound(0), array.Length);
1815 }
1816
1817 public static int IndexOf(Array array, object? value, int startIndex)
1818 {
1819 if (array == null)
1820 {
1822 }
1823 int lowerBound = array.GetLowerBound(0);
1824 return IndexOf(array, value, startIndex, array.Length - startIndex + lowerBound);
1825 }
1826
1827 public static int IndexOf(Array array, object? value, int startIndex, int count)
1828 {
1829 if (array == null)
1830 {
1832 }
1833 if (array.Rank != 1)
1834 {
1835 ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
1836 }
1837 int lowerBound = array.GetLowerBound(0);
1839 {
1841 }
1843 {
1845 }
1846 int num = startIndex + count;
1847 if (array is object[] array2)
1848 {
1849 if (value == null)
1850 {
1851 for (int i = startIndex; i < num; i++)
1852 {
1853 if (array2[i] == null)
1854 {
1855 return i;
1856 }
1857 }
1858 }
1859 else
1860 {
1861 for (int j = startIndex; j < num; j++)
1862 {
1863 object obj = array2[j];
1864 if (obj != null && obj.Equals(value))
1865 {
1866 return j;
1867 }
1868 }
1869 }
1870 return -1;
1871 }
1872 CorElementType corElementTypeOfElementType = array.GetCorElementTypeOfElementType();
1873 if (corElementTypeOfElementType.IsPrimitiveType())
1874 {
1875 if (value == null)
1876 {
1877 return lowerBound - 1;
1878 }
1879 if (array.IsValueOfElementType(value))
1880 {
1882 int num2 = -1;
1884 {
1885 case CorElementType.ELEMENT_TYPE_BOOLEAN:
1886 case CorElementType.ELEMENT_TYPE_I1:
1887 case CorElementType.ELEMENT_TYPE_U1:
1889 break;
1890 case CorElementType.ELEMENT_TYPE_CHAR:
1891 case CorElementType.ELEMENT_TYPE_I2:
1892 case CorElementType.ELEMENT_TYPE_U2:
1894 break;
1895 case CorElementType.ELEMENT_TYPE_I4:
1896 case CorElementType.ELEMENT_TYPE_U4:
1898 break;
1899 case CorElementType.ELEMENT_TYPE_I8:
1900 case CorElementType.ELEMENT_TYPE_U8:
1901 case CorElementType.ELEMENT_TYPE_I:
1902 case CorElementType.ELEMENT_TYPE_U:
1904 break;
1905 case CorElementType.ELEMENT_TYPE_R4:
1907 break;
1908 case CorElementType.ELEMENT_TYPE_R8:
1910 break;
1911 }
1912 return ((num2 >= 0) ? startIndex : lowerBound) + num2;
1913 }
1914 }
1915 for (int k = startIndex; k < num; k++)
1916 {
1917 object value2 = array.GetValue(k);
1918 if (value2 == null)
1919 {
1920 if (value == null)
1921 {
1922 return k;
1923 }
1924 }
1925 else if (value2.Equals(value))
1926 {
1927 return k;
1928 }
1929 }
1930 return lowerBound - 1;
1931 static int GenericIndexOf<T>(Array array, object value, int adjustedIndex, int length) where T : struct, IEquatable<T>
1932 {
1933 return UnsafeArrayAsSpan<T>(array, adjustedIndex, length).IndexOf(Unsafe.As<byte, T>(ref value.GetRawData()));
1934 }
1935 }
1936
1937 public static int IndexOf<T>(T[] array, T value)
1938 {
1939 if (array == null)
1940 {
1942 }
1943 return IndexOf(array, value, 0, array.Length);
1944 }
1945
1946 public static int IndexOf<T>(T[] array, T value, int startIndex)
1947 {
1948 if (array == null)
1949 {
1951 }
1952 return IndexOf(array, value, startIndex, array.Length - startIndex);
1953 }
1954
1955 public static int IndexOf<T>(T[] array, T value, int startIndex, int count)
1956 {
1957 if (array == null)
1958 {
1960 }
1961 if ((uint)startIndex > (uint)array.Length)
1962 {
1964 }
1965 if ((uint)count > (uint)(array.Length - startIndex))
1966 {
1968 }
1969 if (RuntimeHelpers.IsBitwiseEquatable<T>())
1970 {
1971 if (Unsafe.SizeOf<T>() == 1)
1972 {
1974 return ((num >= 0) ? startIndex : 0) + num;
1975 }
1976 if (Unsafe.SizeOf<T>() == 2)
1977 {
1979 return ((num2 >= 0) ? startIndex : 0) + num2;
1980 }
1981 if (Unsafe.SizeOf<T>() == 4)
1982 {
1984 return ((num3 >= 0) ? startIndex : 0) + num3;
1985 }
1986 if (Unsafe.SizeOf<T>() == 8)
1987 {
1989 return ((num4 >= 0) ? startIndex : 0) + num4;
1990 }
1991 }
1992 return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count);
1993 }
1994
1995 public static int LastIndexOf(Array array, object? value)
1996 {
1997 if (array == null)
1998 {
2000 }
2001 int lowerBound = array.GetLowerBound(0);
2002 return LastIndexOf(array, value, array.Length - 1 + lowerBound, array.Length);
2003 }
2004
2005 public static int LastIndexOf(Array array, object? value, int startIndex)
2006 {
2007 if (array == null)
2008 {
2010 }
2011 int lowerBound = array.GetLowerBound(0);
2013 }
2014
2015 public static int LastIndexOf(Array array, object? value, int startIndex, int count)
2016 {
2017 if (array == null)
2018 {
2020 }
2021 int lowerBound = array.GetLowerBound(0);
2022 if (array.Length == 0)
2023 {
2024 return lowerBound - 1;
2025 }
2027 {
2029 }
2030 if (count < 0)
2031 {
2033 }
2034 if (count > startIndex - lowerBound + 1)
2035 {
2036 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.endIndex, ExceptionResource.ArgumentOutOfRange_EndIndexStartIndex);
2037 }
2038 if (array.Rank != 1)
2039 {
2040 ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
2041 }
2042 int num = startIndex - count + 1;
2043 if (array is object[] array2)
2044 {
2045 if (value == null)
2046 {
2047 for (int num2 = startIndex; num2 >= num; num2--)
2048 {
2049 if (array2[num2] == null)
2050 {
2051 return num2;
2052 }
2053 }
2054 }
2055 else
2056 {
2057 for (int num3 = startIndex; num3 >= num; num3--)
2058 {
2059 object obj = array2[num3];
2060 if (obj != null && obj.Equals(value))
2061 {
2062 return num3;
2063 }
2064 }
2065 }
2066 return -1;
2067 }
2068 CorElementType corElementTypeOfElementType = array.GetCorElementTypeOfElementType();
2069 if (corElementTypeOfElementType.IsPrimitiveType())
2070 {
2071 if (value == null)
2072 {
2073 return lowerBound - 1;
2074 }
2075 if (array.IsValueOfElementType(value))
2076 {
2077 int adjustedIndex2 = num - lowerBound;
2078 int num4 = -1;
2080 {
2081 case CorElementType.ELEMENT_TYPE_BOOLEAN:
2082 case CorElementType.ELEMENT_TYPE_I1:
2083 case CorElementType.ELEMENT_TYPE_U1:
2085 break;
2086 case CorElementType.ELEMENT_TYPE_CHAR:
2087 case CorElementType.ELEMENT_TYPE_I2:
2088 case CorElementType.ELEMENT_TYPE_U2:
2090 break;
2091 case CorElementType.ELEMENT_TYPE_I4:
2092 case CorElementType.ELEMENT_TYPE_U4:
2094 break;
2095 case CorElementType.ELEMENT_TYPE_I8:
2096 case CorElementType.ELEMENT_TYPE_U8:
2097 case CorElementType.ELEMENT_TYPE_I:
2098 case CorElementType.ELEMENT_TYPE_U:
2100 break;
2101 case CorElementType.ELEMENT_TYPE_R4:
2103 break;
2104 case CorElementType.ELEMENT_TYPE_R8:
2106 break;
2107 }
2108 return ((num4 >= 0) ? num : lowerBound) + num4;
2109 }
2110 }
2111 for (int num5 = startIndex; num5 >= num; num5--)
2112 {
2113 object value2 = array.GetValue(num5);
2114 if (value2 == null)
2115 {
2116 if (value == null)
2117 {
2118 return num5;
2119 }
2120 }
2121 else if (value2.Equals(value))
2122 {
2123 return num5;
2124 }
2125 }
2126 return lowerBound - 1;
2127 static int GenericLastIndexOf<T>(Array array, object value, int adjustedIndex, int length) where T : struct, IEquatable<T>
2128 {
2129 return UnsafeArrayAsSpan<T>(array, adjustedIndex, length).LastIndexOf(Unsafe.As<byte, T>(ref value.GetRawData()));
2130 }
2131 }
2132
2133 public static int LastIndexOf<T>(T[] array, T value)
2134 {
2135 if (array == null)
2136 {
2138 }
2139 return LastIndexOf(array, value, array.Length - 1, array.Length);
2140 }
2141
2142 public static int LastIndexOf<T>(T[] array, T value, int startIndex)
2143 {
2144 if (array == null)
2145 {
2147 }
2148 return LastIndexOf(array, value, startIndex, (array.Length != 0) ? (startIndex + 1) : 0);
2149 }
2150
2151 public static int LastIndexOf<T>(T[] array, T value, int startIndex, int count)
2152 {
2153 if (array == null)
2154 {
2156 }
2157 if (array.Length == 0)
2158 {
2159 if (startIndex != -1 && startIndex != 0)
2160 {
2162 }
2163 if (count != 0)
2164 {
2166 }
2167 return -1;
2168 }
2169 if ((uint)startIndex >= (uint)array.Length)
2170 {
2172 }
2173 if (count < 0 || startIndex - count + 1 < 0)
2174 {
2176 }
2177 if (RuntimeHelpers.IsBitwiseEquatable<T>())
2178 {
2179 if (Unsafe.SizeOf<T>() == 1)
2180 {
2181 int num = startIndex - count + 1;
2183 return ((num2 >= 0) ? num : 0) + num2;
2184 }
2185 if (Unsafe.SizeOf<T>() == 2)
2186 {
2187 int num3 = startIndex - count + 1;
2189 return ((num4 >= 0) ? num3 : 0) + num4;
2190 }
2191 if (Unsafe.SizeOf<T>() == 4)
2192 {
2193 int num5 = startIndex - count + 1;
2195 return ((num6 >= 0) ? num5 : 0) + num6;
2196 }
2197 if (Unsafe.SizeOf<T>() == 8)
2198 {
2199 int num7 = startIndex - count + 1;
2201 return ((num8 >= 0) ? num7 : 0) + num8;
2202 }
2203 }
2204 return EqualityComparer<T>.Default.LastIndexOf(array, value, startIndex, count);
2205 }
2206
2207 public static void Reverse(Array array)
2208 {
2209 if (array == null)
2210 {
2212 }
2213 Reverse(array, array.GetLowerBound(0), array.Length);
2214 }
2215
2216 public static void Reverse(Array array, int index, int length)
2217 {
2218 if (array == null)
2219 {
2221 }
2222 int lowerBound = array.GetLowerBound(0);
2223 if (index < lowerBound)
2224 {
2226 }
2227 if (length < 0)
2228 {
2230 }
2231 if (array.Length - (index - lowerBound) < length)
2232 {
2234 }
2235 if (array.Rank != 1)
2236 {
2237 ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
2238 }
2239 if (length <= 1)
2240 {
2241 return;
2242 }
2244 switch (array.GetCorElementTypeOfElementType())
2245 {
2246 case CorElementType.ELEMENT_TYPE_BOOLEAN:
2247 case CorElementType.ELEMENT_TYPE_I1:
2248 case CorElementType.ELEMENT_TYPE_U1:
2250 return;
2251 case CorElementType.ELEMENT_TYPE_CHAR:
2252 case CorElementType.ELEMENT_TYPE_I2:
2253 case CorElementType.ELEMENT_TYPE_U2:
2255 return;
2256 case CorElementType.ELEMENT_TYPE_I4:
2257 case CorElementType.ELEMENT_TYPE_U4:
2258 case CorElementType.ELEMENT_TYPE_R4:
2260 return;
2261 case CorElementType.ELEMENT_TYPE_I8:
2262 case CorElementType.ELEMENT_TYPE_U8:
2263 case CorElementType.ELEMENT_TYPE_R8:
2264 case CorElementType.ELEMENT_TYPE_I:
2265 case CorElementType.ELEMENT_TYPE_U:
2267 return;
2268 case CorElementType.ELEMENT_TYPE_ARRAY:
2269 case CorElementType.ELEMENT_TYPE_OBJECT:
2270 case CorElementType.ELEMENT_TYPE_SZARRAY:
2272 return;
2273 }
2274 int num = index;
2275 int num2 = index + length - 1;
2276 while (num < num2)
2277 {
2278 object value = array.GetValue(num);
2279 array.SetValue(array.GetValue(num2), num);
2280 array.SetValue(value, num2);
2281 num++;
2282 num2--;
2283 }
2284 }
2285
2286 public static void Reverse<T>(T[] array)
2287 {
2288 if (array == null)
2289 {
2291 }
2292 Reverse(array, 0, array.Length);
2293 }
2294
2295 public static void Reverse<T>(T[] array, int index, int length)
2296 {
2297 if (array == null)
2298 {
2300 }
2301 if (index < 0)
2302 {
2304 }
2305 if (length < 0)
2306 {
2308 }
2309 if (array.Length - index < length)
2310 {
2312 }
2313 if (length > 1)
2314 {
2316 ref T reference2 = ref Unsafe.Add(ref Unsafe.Add(ref reference, length), -1);
2317 do
2318 {
2319 T val = reference;
2321 reference2 = val;
2322 reference = ref Unsafe.Add(ref reference, 1);
2323 reference2 = ref Unsafe.Add(ref reference2, -1);
2324 }
2325 while (Unsafe.IsAddressLessThan(ref reference, ref reference2));
2326 }
2327 }
2328
2329 public static void Sort(Array array)
2330 {
2331 if (array == null)
2332 {
2334 }
2335 Sort(array, null, array.GetLowerBound(0), array.Length, null);
2336 }
2337
2338 public static void Sort(Array keys, Array? items)
2339 {
2340 if (keys == null)
2341 {
2343 }
2344 Sort(keys, items, keys.GetLowerBound(0), keys.Length, null);
2345 }
2346
2347 public static void Sort(Array array, int index, int length)
2348 {
2349 Sort(array, null, index, length, null);
2350 }
2351
2352 public static void Sort(Array keys, Array? items, int index, int length)
2353 {
2354 Sort(keys, items, index, length, null);
2355 }
2356
2357 public static void Sort(Array array, IComparer? comparer)
2358 {
2359 if (array == null)
2360 {
2362 }
2363 Sort(array, null, array.GetLowerBound(0), array.Length, comparer);
2364 }
2365
2366 public static void Sort(Array keys, Array? items, IComparer? comparer)
2367 {
2368 if (keys == null)
2369 {
2371 }
2372 Sort(keys, items, keys.GetLowerBound(0), keys.Length, comparer);
2373 }
2374
2375 public static void Sort(Array array, int index, int length, IComparer? comparer)
2376 {
2377 Sort(array, null, index, length, comparer);
2378 }
2379
2380 public static void Sort(Array keys, Array? items, int index, int length, IComparer? comparer)
2381 {
2382 if (keys == null)
2383 {
2385 }
2386 if (keys.Rank != 1 || (items != null && items.Rank != 1))
2387 {
2388 ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported);
2389 }
2390 int lowerBound = keys.GetLowerBound(0);
2391 if (items != null && lowerBound != items.GetLowerBound(0))
2392 {
2393 ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_LowerBoundsMustMatch);
2394 }
2395 if (index < lowerBound)
2396 {
2398 }
2399 if (length < 0)
2400 {
2402 }
2403 if (keys.Length - (index - lowerBound) < length || (items != null && index - lowerBound > items.Length - length))
2404 {
2406 }
2407 if (length <= 1)
2408 {
2409 return;
2410 }
2411 if (comparer == null)
2412 {
2414 }
2415 if (keys is object[] keys2)
2416 {
2417 object[] array = items as object[];
2418 if (items == null || array != null)
2419 {
2421 return;
2422 }
2423 }
2424 if (comparer == Comparer.Default)
2425 {
2426 CorElementType corElementTypeOfElementType = keys.GetCorElementTypeOfElementType();
2427 if (items == null || items.GetCorElementTypeOfElementType() == corElementTypeOfElementType)
2428 {
2431 {
2432 case CorElementType.ELEMENT_TYPE_I1:
2434 return;
2435 case CorElementType.ELEMENT_TYPE_BOOLEAN:
2436 case CorElementType.ELEMENT_TYPE_U1:
2438 return;
2439 case CorElementType.ELEMENT_TYPE_I2:
2441 return;
2442 case CorElementType.ELEMENT_TYPE_CHAR:
2443 case CorElementType.ELEMENT_TYPE_U2:
2445 return;
2446 case CorElementType.ELEMENT_TYPE_I4:
2448 return;
2449 case CorElementType.ELEMENT_TYPE_U4:
2451 return;
2452 case CorElementType.ELEMENT_TYPE_I8:
2453 case CorElementType.ELEMENT_TYPE_I:
2455 return;
2456 case CorElementType.ELEMENT_TYPE_U8:
2457 case CorElementType.ELEMENT_TYPE_U:
2459 return;
2460 case CorElementType.ELEMENT_TYPE_R4:
2462 return;
2463 case CorElementType.ELEMENT_TYPE_R8:
2465 return;
2466 }
2467 }
2468 }
2470 static void GenericSort<T>(Array keys, Array items, int adjustedIndex, int length) where T : struct
2471 {
2473 if (items != null)
2474 {
2476 }
2477 else
2478 {
2479 span.Sort();
2480 }
2481 }
2482 }
2483
2484 public static void Sort<T>(T[] array)
2485 {
2486 if (array == null)
2487 {
2489 }
2490 if (array.Length > 1)
2491 {
2493 ArraySortHelper<T>.Default.Sort(keys, null);
2494 }
2495 }
2496
2497 public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items)
2498 {
2499 if (keys == null)
2500 {
2502 }
2503 Sort(keys, items, 0, keys.Length, null);
2504 }
2505
2506 public static void Sort<T>(T[] array, int index, int length)
2507 {
2508 Sort(array, index, length, null);
2509 }
2510
2511 public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, int index, int length)
2512 {
2513 Sort(keys, items, index, length, null);
2514 }
2515
2516 public static void Sort<T>(T[] array, IComparer<T>? comparer)
2517 {
2518 if (array == null)
2519 {
2521 }
2522 Sort(array, 0, array.Length, comparer);
2523 }
2524
2525 public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, IComparer<TKey>? comparer)
2526 {
2527 if (keys == null)
2528 {
2530 }
2531 Sort(keys, items, 0, keys.Length, comparer);
2532 }
2533
2534 public static void Sort<T>(T[] array, int index, int length, IComparer<T>? comparer)
2535 {
2536 if (array == null)
2537 {
2539 }
2540 if (index < 0)
2541 {
2543 }
2544 if (length < 0)
2545 {
2547 }
2548 if (array.Length - index < length)
2549 {
2551 }
2552 if (length > 1)
2553 {
2555 ArraySortHelper<T>.Default.Sort(keys, comparer);
2556 }
2557 }
2558
2559 public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, int index, int length, IComparer<TKey>? comparer)
2560 {
2561 if (keys == null)
2562 {
2564 }
2565 if (index < 0)
2566 {
2568 }
2569 if (length < 0)
2570 {
2572 }
2573 if (keys.Length - index < length || (items != null && index > items.Length - length))
2574 {
2576 }
2577 if (length > 1)
2578 {
2579 if (items == null)
2580 {
2582 return;
2583 }
2587 }
2588 }
2589
2590 public static void Sort<T>(T[] array, Comparison<T> comparison)
2591 {
2592 if (array == null)
2593 {
2595 }
2596 if (comparison == null)
2597 {
2599 }
2602 }
2603
2604 public static bool TrueForAll<T>(T[] array, Predicate<T> match)
2605 {
2606 if (array == null)
2607 {
2609 }
2610 if (match == null)
2611 {
2613 }
2614 for (int i = 0; i < array.Length; i++)
2615 {
2616 if (!match(array[i]))
2617 {
2618 return false;
2619 }
2620 }
2621 return true;
2622 }
2623
2625 {
2626 return new Span<T>(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), array.Length).Slice(adjustedIndex, length);
2627 }
2628
2630 {
2631 return new ArrayEnumerator(this);
2632 }
2633}
static readonly T[] Value
Definition Array.cs:19
static int LastIndexOf(Array array, object? value, int startIndex, int count)
Definition Array.cs:2015
static unsafe void Clear(Array array, int index, int length)
Definition Array.cs:774
int GetUpperBound(int dimension)
Definition Array.cs:853
static unsafe Array InternalCreate(void *elementType, int rank, int *pLengths, int *pLowerBounds)
static void Sort(Array array)
Definition Array.cs:2329
static void Sort(Array keys, Array? items)
Definition Array.cs:2338
static unsafe Array CreateInstance(Type elementType, params int[] lengths)
Definition Array.cs:546
bool IsReadOnly
Definition Array.cs:453
static void Sort< T >(T[] array)
Definition Array.cs:2484
static Span< T > UnsafeArrayAsSpan< T >(Array array, int adjustedIndex, int length)
Definition Array.cs:2624
static void Sort(Array array, int index, int length, IComparer? comparer)
Definition Array.cs:2375
void Initialize()
static void Reverse(Array array)
Definition Array.cs:2207
object? GetValue(params int[] indices)
Definition Array.cs:980
static unsafe Array CreateInstance(Type elementType, int length1, int length2, int length3)
Definition Array.cs:516
unsafe? object GetValue(int index)
Definition Array.cs:993
void CopyTo(Array array, long index)
Definition Array.cs:1564
int Length
Definition Array.cs:430
static T[] FindAll< T >(T[] array, Predicate< T > match)
Definition Array.cs:1650
static void Sort(Array keys, Array? items, int index, int length, IComparer? comparer)
Definition Array.cs:2380
void IList. Clear()
Definition Array.cs:1223
void SetValue(object? value, int index1, int index2, int index3)
Definition Array.cs:1041
static int FindLastIndex< T >(T[] array, Predicate< T > match)
Definition Array.cs:1738
static int FindIndex< T >(T[] array, Predicate< T > match)
Definition Array.cs:1671
static void Sort(Array array, int index, int length)
Definition Array.cs:2347
void SetValue(object? value, long index1, long index2)
Definition Array.cs:1143
static int BinarySearch< T >(T[] array, T value)
Definition Array.cs:1493
static int IndexOf(Array array, object? value, int startIndex)
Definition Array.cs:1817
static void Sort(Array keys, Array? items, int index, int length)
Definition Array.cs:2352
static void Reverse< T >(T[] array)
Definition Array.cs:2286
object SyncRoot
Definition Array.cs:451
static void CopySlow(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
static void Sort< TKey, TValue >(TKey[] keys, TValue[]? items)
Definition Array.cs:2497
object InternalGetValue(nint flattenedIndex)
static bool TrueForAll< T >(T[] array, Predicate< T > match)
Definition Array.cs:2604
static int BinarySearch(Array array, object? value, IComparer? comparer)
Definition Array.cs:1334
object? GetValue(long index1, long index2)
Definition Array.cs:1074
long GetLongLength(int dimension)
Definition Array.cs:1207
object? GetValue(int index1, int index2)
Definition Array.cs:1002
void SetValue(object? value, long index1, long index2, long index3)
Definition Array.cs:1158
static T[] Empty< T >()
Definition Array.cs:1574
static int BinarySearch(Array array, int index, int length, object? value)
Definition Array.cs:1329
static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length)
Definition Array.cs:960
int IList. IndexOf(object value)
Definition Array.cs:1228
static int MaxLength
Definition Array.cs:471
static void Resize< T >([NotNull] ref T[]? array, int newSize)
Definition Array.cs:907
object? GetValue(int index1, int index2, int index3)
Definition Array.cs:1012
static int LastIndexOf(Array array, object? value)
Definition Array.cs:1995
IEnumerator GetEnumerator()
Definition Array.cs:2629
static int IndexOf< T >(T[] array, T value)
Definition Array.cs:1937
static void Fill< T >(T[] array, T value)
Definition Array.cs:1584
static void Sort(Array array, IComparer? comparer)
Definition Array.cs:2357
static unsafe Array CreateInstance(Type elementType, int length)
Definition Array.cs:473
static unsafe void Clear(Array array)
Definition Array.cs:755
static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable)
Definition Array.cs:680
static unsafe Array CreateInstance(Type elementType, int length1, int length2)
Definition Array.cs:491
void SetValue(object? value, int index1, int index2)
Definition Array.cs:1031
static ? T FindLast< T >(T[] array, Predicate< T > match)
Definition Array.cs:1718
static int IndexOf(Array array, object? value, int startIndex, int count)
Definition Array.cs:1827
static int IndexOf(Array array, object? value)
Definition Array.cs:1808
object? GetValue(long index)
Definition Array.cs:1064
unsafe nint GetFlattenedIndex(ReadOnlySpan< int > indices)
Definition Array.cs:807
static int BinarySearch(Array array, int index, int length, object? value, IComparer? comparer)
Definition Array.cs:1343
static int BinarySearch(Array array, object? value)
Definition Array.cs:1320
static void Reverse(Array array, int index, int length)
Definition Array.cs:2216
bool IsFixedSize
Definition Array.cs:455
static bool IsSimpleCopy(Array sourceArray, Array destinationArray)
void CopyTo(Array array, int index)
Definition Array.cs:1555
static int LastIndexOf< T >(T[] array, T value)
Definition Array.cs:2133
static ? T Find< T >(T[] array, Predicate< T > match)
Definition Array.cs:1630
static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
Definition Array.cs:750
static int LastIndexOf(Array array, object? value, int startIndex)
Definition Array.cs:2005
void InternalSetValue(object value, nint flattenedIndex)
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
unsafe void SetValue(object? value, int index)
Definition Array.cs:1022
bool IsSynchronized
Definition Array.cs:457
static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length)
Definition Array.cs:655
unsafe bool IsValueOfElementType(object value)
Definition Array.cs:885
static int GetMedian(int low, int hi)
Definition Array.cs:1202
CorElementType GetCorElementTypeOfElementType()
static ReadOnlyCollection< T > AsReadOnly< T >(T[] array)
Definition Array.cs:898
static void Sort(Array keys, Array? items, IComparer? comparer)
Definition Array.cs:2366
int GetLength(int dimension)
Definition Array.cs:839
void SetValue(object? value, long index)
Definition Array.cs:1133
object? GetValue(params long[] indices)
Definition Array.cs:1109
static Array CreateInstance(Type elementType, params long[] lengths)
Definition Array.cs:926
static void ForEach< T >(T[] array, Action< T > action)
Definition Array.cs:1792
object Clone()
Definition Array.cs:1249
static bool Exists< T >(T[] array, Predicate< T > match)
Definition Array.cs:1579
int GetLowerBound(int dimension)
Definition Array.cs:868
nuint NativeLength
Definition Array.cs:432
static void Copy(Array sourceArray, Array destinationArray, long length)
Definition Array.cs:950
object? GetValue(long index1, long index2, long index3)
Definition Array.cs:1089
void SetValue(object? value, params int[] indices)
Definition Array.cs:1051
void SetValue(object? value, params long[] indices)
Definition Array.cs:1178
static TOutput[] ConvertAll< TInput, TOutput >(TInput[] array, Converter< TInput, TOutput > converter)
Definition Array.cs:1537
static unsafe Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds)
Definition Array.cs:578
long LongLength
Definition Array.cs:434
static void BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
Definition Buffer.cs:31
static void Memmove(ref byte dest, ref byte src, nuint len)
Definition Buffer.cs:215
static Comparer< T > Default
Definition Comparer.cs:11
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static int Log2(uint value)
static unsafe int GetMultiDimensionalArrayRank(Array array)
static unsafe MethodTable * GetMethodTable(object obj)
static ref int GetMultiDimensionalArrayBounds(Array array)
static unsafe ref byte GetArrayDataReference(Array array)
static string ArrayTypeMismatch_ConstrainedCopy
Definition SR.cs:1132
static string Arg_LongerThanDestArray
Definition SR.cs:228
static string IndexOutOfRange_ArrayRankIndex
Definition SR.cs:1362
static string ArgumentOutOfRange_ArrayLB
Definition SR.cs:970
static string Rank_MustMatch
Definition SR.cs:1828
static string Arg_LongerThanSrcArray
Definition SR.cs:230
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7
static void ClearWithReferences(ref IntPtr ip, nuint pointerSizeLength)
static void ClearWithoutReferences(ref byte b, nuint byteLength)
static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
static void ThrowNotSupportedException(ExceptionResource resource)
static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count()
static void ThrowIndexOutOfRangeException()
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowArgumentException_BadComparer(object comparer)
static void ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum()
static void ThrowInvalidOperationException()
static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index()
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException()
static void ThrowRankException(ExceptionResource resource)
void Insert(int index, T item)
int CompareTo(object? other, IComparer comparer)
int GetHashCode(IEqualityComparer comparer)
bool Equals(object? other, IEqualityComparer comparer)
void Swap(int i, int j)
Definition Array.cs:258
int PickPivotAndPartition(int lo, int hi)
Definition Array.cs:331
void DownHeap(int i, int n, int lo)
Definition Array.cs:376
void IntrospectiveSort(int left, int length)
Definition Array.cs:276
void SwapIfGreater(int a, int b)
Definition Array.cs:242
SorterGenericArray(Array keys, Array items, IComparer comparer)
Definition Array.cs:235
void Heapsort(int lo, int hi)
Definition Array.cs:362
void InsertionSort(int lo, int hi)
Definition Array.cs:405
readonly IComparer comparer
Definition Array.cs:233
void Sort(int left, int length)
Definition Array.cs:271
void IntroSort(int lo, int hi, int depthLimit)
Definition Array.cs:296
void Heapsort(int lo, int hi)
Definition Array.cs:157
void Swap(int i, int j)
Definition Array.cs:53
void IntroSort(int lo, int hi, int depthLimit)
Definition Array.cs:91
void InsertionSort(int lo, int hi)
Definition Array.cs:201
void IntrospectiveSort(int left, int length)
Definition Array.cs:71
SorterObjectArray(object[] keys, object[] items, IComparer comparer)
Definition Array.cs:30
void DownHeap(int i, int n, int lo)
Definition Array.cs:171
readonly object[] items
Definition Array.cs:26
int PickPivotAndPartition(int lo, int hi)
Definition Array.cs:126
void SwapIfGreater(int a, int b)
Definition Array.cs:37
readonly object[] keys
Definition Array.cs:24
readonly IComparer comparer
Definition Array.cs:28
void Sort(int left, int length)
Definition Array.cs:66
void Add(int value)
Definition HashCode.cs:239