コード例 #1
0
        private static ByReference <T> InternalAddress(T[,,,] array, int index1, int index2, int index3, int index4)
        {
            MDArrayRank4 <T> mdArrayObj = Unsafe.As <MDArrayRank4 <T> >(array);

            if ((index1 < 0) || (index1 >= mdArrayObj._upperBound1))
            {
                throw new IndexOutOfRangeException();
            }
            if ((index2 < 0) || (index2 >= mdArrayObj._upperBound2))
            {
                throw new IndexOutOfRangeException();
            }
            if ((index3 < 0) || (index3 >= mdArrayObj._upperBound3))
            {
                throw new IndexOutOfRangeException();
            }
            if ((index4 < 0) || (index4 >= mdArrayObj._upperBound4))
            {
                throw new IndexOutOfRangeException();
            }

            int index = (((((index1 * mdArrayObj._upperBound2) + index2) * mdArrayObj._upperBound3) + index3) * mdArrayObj._upperBound4) + index4;


            int offset = ByReference <T> .SizeOfT() * index + 4 * 8;

            ByReference <int> _upperBound1Ref = ByReference <int> .FromRef(ref mdArrayObj._upperBound1);

            return(ByReference <int> .Cast <T>(ByReference <int> .AddRaw(_upperBound1Ref, offset)));
        }
コード例 #2
0
        public static T[,,,] Ctor(int length1, int length2, int length3, int length4)
        {
            if ((length1 < 0) || (length2 < 0) || (length3 < 0) || (length4 < 0))
            {
                throw new OverflowException();
            }
            MDArrayRank4 <T> newArray = Unsafe.As <MDArrayRank4 <T> >(RuntimeImports.RhNewArray(typeof(T[, , , ]).TypeHandle.ToEETypePtr(), checked (length1 * length2 * length3 * length4)));

            newArray._upperBound1 = length1;
            newArray._upperBound2 = length2;
            newArray._upperBound3 = length3;
            newArray._upperBound4 = length4;
            return(Unsafe.As <T[, , , ]>(newArray));
        }