示例#1
0
        private static ByReference <T> InternalAddress(T[,,] array, int index1, int index2, int index3)
        {
            MDArrayRank3 <T> mdArrayObj = Unsafe.As <MDArrayRank3 <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();
            }

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

            int offset = ByReference <T> .SizeOfT() * index + 3 * 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)
        {
            if ((length1 < 0) || (length2 < 0) || (length3 < 0))
            {
                throw new OverflowException();
            }
            MDArrayRank3 <T> newArray = Unsafe.As <MDArrayRank3 <T> >(RuntimeImports.RhNewArray(typeof(T[, , ]).TypeHandle.ToEETypePtr(), checked (length1 * length2 * length3)));

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