我的不安全方法接受集合
byte[]
字节[]
我需要遍历它们,寻找特定的模式。搜索本质上是一种重新解释类型的方式:在每个偏移处,我需要考虑一个值,就好像它是一个float,double,short,int,等等一样
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]++;
}
}
}
本质上,问题是如何初始化
pointers
地址是
arrays
,同时固定数组,以便GC不会移动它们。