Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetFlattenedIndex()

unsafe nint System.Array.GetFlattenedIndex ( ReadOnlySpan< int > indices)
inlineprivate

Definition at line 807 of file Array.cs.

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 {
819 ThrowHelper.ThrowIndexOutOfRangeException();
820 }
821 num = num3 * num + num2;
822 }
823 return num;
824 }
825 int num4 = indices[0];
826 if ((uint)num4 >= (uint)LongLength)
827 {
828 ThrowHelper.ThrowIndexOutOfRangeException();
829 }
830 return num4;
831 }
long LongLength
Definition Array.cs:434
static unsafe MethodTable * GetMethodTable(object obj)
static ref int GetMultiDimensionalArrayBounds(Array array)

References System.Runtime.CompilerServices.RuntimeHelpers.GetMethodTable(), System.Runtime.CompilerServices.RuntimeHelpers.GetMultiDimensionalArrayBounds(), System.indices, System.Array.LongLength, and System.ThrowHelper.ThrowIndexOutOfRangeException().

Referenced by System.Array.GetValue(), System.Array.GetValue(), System.Array.GetValue(), System.Array.GetValue(), System.Array.SetValue(), System.Array.SetValue(), System.Array.SetValue(), and System.Array.SetValue().