用< \\ text / hash_map>替换std :: map [英] replace std::map with <ext/hash_map>

查看:90
本文介绍了用< \\ text / hash_map>替换std :: map的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!


我想用hash_map替换std :: map< std :: string,Services *>

。我会做什么这个?


任何带示例的链接?


transactions.insert(std :: pair< std :: string,Services *>( Aservice,新

xxxx));

transactions.insert(std :: pair< std :: string,Services *>(" Vservice",新的

fffff));

transactions.insert(std :: pair< std :: string,Services *>(" Rservice",new

ttt));

...............


我应该如何用hash_map替换它?


感谢您的帮助。

hello!

I wanna replace an std::map<std::string,Services*>
with hash_map.How I will do this?

any link with examples?

transactions.insert(std::pair<std::string,Services *>("Aservice",new
xxxx));
transactions.insert(std::pair<std::string,Services *>("Vservice",new
fffff));
transactions.insert(std::pair<std::string,Services *>("Rservice",new
ttt));
...............

how I should replace this with hash_map?

thanks for any help.

推荐答案

g写道:
我想用hash_map替换std :: map< std :: string,Services *>
我会这样做吗?


什么是'hash_map"?没有这样的标准结构(无论如何)。

带示例的任何链接?


你试过Google吗?

transactions.insert(std :: pair< std :: string,Services *>(" Aservice",new
xxxx));
transactions.insert(std :: pair< std :: string,Services *>(" Vservice",new
fffff));
交易.insert(std :: pair< std :: string,Services *>(" Rservice",new
ttt));
.............. 。

我应该如何用hash_map替换它?
I wanna replace an std::map<std::string,Services*>
with hash_map.How I will do this?
What''s "hash_map"? There is no such standard construct (yet, anyway).
any link with examples?
Have you tried Google?
transactions.insert(std::pair<std::string,Services *>("Aservice",new
xxxx));
transactions.insert(std::pair<std::string,Services *>("Vservice",new
fffff));
transactions.insert(std::pair<std::string,Services *>("Rservice",new
ttt));
...............

how I should replace this with hash_map?




它完全取决于''hash_map''暴露什么以及它有什么接口。

你认为知道什么是hash_map吗?这是先决条件吗?这不是
。它是否符合关联容器的要求?

如果确实如此,你可能需要使用''hash_map :: value_type''而不是

''std: :对''。也许这是一回事。也许不吧。你实际上是否已经尝试编译以确定它是否失败?如果是,它在哪里失败并且

会出现什么错误消息?如果没有,为什么不呢?


V

-

请在回复e时删除资金'A'邮件

我没有回复最热门的回复,请不要问



It depends entirely what ''hash_map'' exposes and what interface it has.
Do you think that knowing what "hash_map" is a prerequisite here? It''s
not. Does it comply with the requirements for an associative container?
If it does, you probably need to use ''hash_map::value_type'' instead of
''std::pair''. Maybe it''s the same thing. Maybe not. Have you actually
tried compiling to see if it fails? If yes, where does it fail and with
what error message? If not, why not?

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


文章< e2 **** ******@news.datemas.de> ;,

" Victor Bazarov" <五******** @ comAcast.net>写道:
In article <e2**********@news.datemas.de>,
"Victor Bazarov" <v.********@comAcast.net> wrote:
g写道:
我想用hash_map替换std :: map< std :: string,Services *>
。我将如何做到这一点?
I wanna replace an std::map<std::string,Services*>
with hash_map.How I will do this?



什么是'hash_map"?没有这样的标准结构(但是,无论如何)。



What''s "hash_map"? There is no such standard construct (yet, anyway).




Fwiw,当它(不是)成为标准时,可能的名称是

std :: unordered_map。


-Howard



Fwiw, when (not if) it becomes standard, the likely name is
std::unordered_map.

-Howard


嗨!

我正在使用谷歌搜索但我找不到东西......


我想使用gnu / sgi扩展名


这段代码没有编译,它来自我的std :: map

transactions.insert(std :: pair< std :: string,Services *>(" Aservice",new

xxxx));


我想将其转换为hash_map .....


hash_map< std :: string,服务*,散列<的std :: string>>交易;


这是正确的声明吗?

hi !
I am googling but I haven''t found something......

I wanna use the gnu/sgi extension

this code doesn''t compile,it''s from my std::map
transactions.insert(std::pair<std::string,Services *>("Aservice",new
xxxx));

I want to convert it to hash_map.....

hash_map<std::string,Services*,hash<std::string>> transactions;

this is the correct declaration?


这篇关于用&lt; \\ text / hash_map&gt;替换std :: map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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