在内存中以便矩形阵列的物理 [英] Rectangular array physical in memory order

查看:154
本文介绍了在内存中以便矩形阵列的物理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C,在阵列说 A [2] [3] 最右边的指数的变化导致了最小的内存地址的转变,即元素被定位在内存中 A [0] [0],A [0] [1] ...

In C, in array say A[2][3] rightmost index change resulted in a smallest memory address shift, i.e. elements were located in memory as A[0][0], A[0][1]...

时同样适用于在.NET矩形阵列?如果我们有,说阵列 A [2,3] 是位于存储元件的 A [0,0],一个[0,1] ...

Is same is true for rectangular arrays in .NET? If we have, say array a[2, 3] are elements located in memory as a[0, 0], a[0, 1]...?

推荐答案

CLI规范,第8.9.1规定:

The CLI specification, section 8.9.1, states:

数组元素应进行布局数组对象中的行优先   顺序(即最右边的数组元素相关联   尺寸应当连续布局从低到高   指数)。分配给每个数组元素的实际寄存   包括平台特定的填充。

Array elements shall be laid out within the array object in row-major order (i.e., the elements associated with the rightmost array dimension shall be laid out contiguously from lowest to highest index). The actual storage allocated for each array element can include platform-specific padding.

因此​​,答案是肯定的 - 你会先遇到的第一个行的所有元素,第二行,等那么所有元素(如规范说,这就是所谓的行优先顺序排列的)。

So the answer is yes -- you will first encounter all elements of the first row, then all elements of the second row, etc (as the spec says, this is called row-major order).

这篇关于在内存中以便矩形阵列的物理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆