我不安全的方法接受一个集合byte[]
秒。所有这些byte[]
都是相同的大小。初始化字节*集合在C#
我需要遍历所有这些,寻找一定的模式。搜索本质上是重新诠释铸风格:在每个偏移,我需要考虑的值就好像它是一个浮动,双,短,一个int,等于是得到一个byte*
每个输入byte[]
和增加它的每个迭代似乎是一种自然的方法。
不幸的是我无法找到任何方式来创建的byte*
集合 - 或更具体地说,从阵列的集合初始化。有任何想法吗?
这里的任务的有点做作的版本:
static unsafe void SearchIteration(List<byte[]> arrays, byte[] resultArr)
{
fixed (byte* resultFix = resultArr)
{
byte* resultPtr = resultFix;
byte*[] pointers = new byte*[arrays.Count];
<some code to fix all the arrays and store the pointers in "pointers">
int remaining = resultArr.Length;
while (remaining > 0)
{
<look at resultPtr and each of the pointers and update *resultPtr>
remaining--;
for (int i = 0; i < pointers.Length; i++)
pointers[i]++;
}
}
}
本质的问题是如何与arrays
地址初始化pointers
,而钉扎阵列,使GC不动他们。
究竟什么是您的对象的集合,什么是字节[]? – Raynos 2010-08-24 20:23:16
你真的需要让所有的byte []数组中在同一时间被固定,或者你可以处理这些接二连三? – dtb 2010-08-24 20:28:22
@Raynos对不起,我简化了一下,忘了删除一个对象的引用。现在走了。只是'byte []'s。 – 2010-08-24 20:32:01