答复: [cpp] 怎么高效实现从char[] 到byte的转换?
Wu Yongwei
adah at sh163.net
Wed Apr 11 20:43:55 CST 2007
来晚了些,不过还是希望能提供有用的信息。
如果字符串比较短,比如,小于四字节或者八字节的话,可以直接把对应的整数当
成哈希值(或排序参照)。我以前实现并比较过速度:
http://wyw.dcweb.cn/mstring.htm
Fei Xu的要求可以实现成:
hash_map<mstring> dict;
...
string s;
...
if (dict.find(s.c_str()) != dict.end()) {
// Found
}
吴咏炜
Leon wrote:
> sigh,简单问题被我说复杂了,总而言之没有其他限制情况下,直接用一个现有的
> Hashtable 或 hashmap模板,那样就不用自己实现hashcode函数;
> 要么就自己实现一个hashtable,那么就需要自己提供hashcode函数,去用lua的
> hashcode计算函数即可。
>
> -----邮件原件-----
> 发件人: cpp-bounces at codingnow.com [mailto:cpp-bounces at codingnow.com] 代表
> hit_pc
> 发送时间: 2007年3月20日 13:15
> 收件人: C++ Discuss Group
> 主题: Re: [cpp] 怎么高效实现从char[] 到byte的转换?
>
>
> On Tue, 20 Mar 2007 12:30:06 +0800, Fei Xu <flyingxu at gmail.com> wrote:
>
>
>>比如有这样的一个表:
>>mov 01
>>add 02
>>div 03
>>...
>>end 99
More information about the Cpp
mailing list