首先,我想告诉你,我的整体/主要针对的是使用它们的功能名称(字符串)作为参数来执行某些功能,我定义的函数如下: (我想生成用于我插入作为参数传递给函数的每个字符串数据的唯一号码)性能stdext ::哈希值()中定义的std ::的hash_set
#include <iostream>
#include <string>
#include <hash_set>
using namespace std;
void Func_Execution(string &s){
int k=stdext::hash_value(s);
#if(_MSC_VER ==1500)
switch (k)
{
case -336300864: GETBATTERYCALLSIGNS();
break;
case -1859542241:GETGUNIDS();
break;
case 323320073:Foo(); // here int k=323320073 for string s="Foo"
break;
case 478877555:Bar();
break;
defalut :Exit();
break;
}
#endif
}
在这里,我打电话Func_Execution功能如下:
void main(){
string s="Foo";
Func_Execution(s);
}
欲知道这是否有效(考虑性能/时间)消费)和有效的机制,为特定的字符串(字符模式)生成一个唯一的数值,而不是使用stdext :: hash_value()函数?(另外注意我也想实现开关情况)
那'#endif'是错误的。 –
谢谢你..我的不好:| –
另外,你确定'hash_value'函数将为某个字符串* always *返回相同的散列吗?即使你更新了编译器/库?在所有支持的平台上? –