比较字节数组通配符 [英] Compare byte array wildscards

查看:79
本文介绍了比较字节数组通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

抱歉,标题有些混乱,我不知道如何用不同的方式来描述它.
这是过去几天一直困扰着我的大脑的问题.

我需要相互比较2个字节的数组,这很简单.
但是现在我需要将2个通配符添加到一个字节数组中.

问题是我怎么知道我应该使用通配符代码而不是直接比较.
现在,如果我可以做类似(byte)256是整数通配符和(byte)257是字符通配符之类的事情,但这是不可能的.
另一个想法是在数组中使用null,所以我知道它是一个通配符,我可以从那里去,但这也是不可能的.

我唯一的另一个想法是使用arraylist,并添加一个不同的数据类型,但这每次都需要typeof(),而速度是应用程序的主要焦点,因此我尝试避免使用此选项.

有人有什么想法吗?
谢谢分配!

Hey all,

Sorry for the somewhat confusing title, i don''t know how to describe it differently.
Here is the problem that''s been wrecking havoc on my brains the past days.

I need to compare 2 byte arrays with each other, this is quite simple.
But now i need to add 2 wildcards to one of the byte arrays.

The problem is how do i know i supposed to use the wildcard code instead of direct comparing.
Now if i could do something like (byte)256 is integer wildcard and (byte)257 is an character wildcard, but this is not possible.
The other idea was use null in the array so i know it''s a wildcard and i can go from there but this is also not possible.

The only other idea i had is use an arraylist, and add a different datatype but this would require typeof() everytime, and the speed is the main focus of the application so i am trying to avoid this option.

Does anyone have any ideas?
Thanks allot!

推荐答案

您可以

0)创建一对字典,以保存通配符位置的位置和值(每个数组一个字典)

1)将通配符字节(例如"FF")插入这些位置

2)执行比较

3)将原始值替换为字典中的原始位置
You could

0) create a pair of dictionaries that hold the position and value of the wildcard positions (one dictionary for each array)

1) Plug a wildcard byte (say, "FF") to those positions

2) Perform the comparison

3) Replace the original values at their original positions from the dictionaries


为什么我没有想到呢.

与程序集调试器断点相同.
只需将原始字节替换为CC,然后恢复原始字节即可.

或者在我的情况下,如果字节为0xFF,请检查它是通配符还是普通字节,
简单而又天才.

谢谢!!
Why didn''t i think of that.

That the same as an assembly debugger breakpoint.
Just replace the original byte with CC and then restore the original byte.

Or in my case if the byte is 0xFF check it''s a wildcard or a normal byte,
Simple yet genius.

Thanks!!


这篇关于比较字节数组通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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