Array.Reverse() 方法背后的逻辑
public static void Reverse(Array array, int index, int length); 背后的本机逻辑工作是什么?
what is the native logic work behind public static void Reverse(Array array, int index, int length);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
您可以使用 .NET Reflector 来实现此目的:
TrySZReverse 是一种本机方法,有时可以做同样的事情只会更快。
You can use .NET Reflector for that:
TrySZReverse is a native method that can sometimes do the same thing only faster.
从起点
index
循环到范围的中间index + length/2
,将每个array[i]
与 <代码>数组[索引+长度-i-1]。Loop from the starting point,
index
, to the middle of the range,index + length/2
, swapping eacharray[i]
witharray[index + length - i - 1]
.有关本机方法“TrySZReverse”的一些详细信息
coreclr([1][ 2]),TrySZReverse处理原始类型的数组,其反向算法与Array.Reverse相同:
代码引用
,前缀“SZ”似乎代表“单维零终止”。
Some details about the native method "TrySZReverse"
from the related codes from coreclr([1][2]), TrySZReverse handles the array of primitive types, and the reverse algorithm is the same as Array.Reverse :
codes quotation
and the prefix "SZ" seems stands for "single-dimension zero-terminated".