STL地图问题 [英] STL map question

查看:56
本文介绍了STL地图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


首先,我知道我的问题与STL有关。

但是comp.std.c ++组经过审核,我不知道要花多长时间才能在那里回答。所以,请你着火。


现在的问题是:


是否有任何特殊原因(性能等)使用"(* i).second"

而不是i-> second?


示例如下:


typedef std :: map< ...>表;


extern table t;

table :: iterator i;

for(i = t.begin(); i!= t.end(); i ++)

{

param =(* i).second;

...

}


谢谢。

Hello all,

First of all I am aware of the fact that my question is STL related.
However the comp.std.c++ group is moderated and I have no idea how long
it will take to be answered there. So, please, hold your fire.

And now the question:

Is there any special reason (performance, etc.) for using "(*i).second"
instead of "i->second"?

The example follows:

typedef std::map<...> table;

extern table t;
table::iterator i;
for (i=t.begin(); i!=t.end(); i++)
{
param = (*i).second;
...
}

Thanks.

推荐答案

" brian" <峰; br *********** @ yahoo.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
"brian" <br***********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
首先,我知道我的问题与STL有关。
然而comp.std.c ++组被审核,我不知道它将需要多长时间在那里回答。所以,请你举起火来。
欢迎所有C ++问题,没有预料之火。

是否有任何特殊原因(性能等)使用(* i).second
而不是i-> second?
First of all I am aware of the fact that my question is STL related.
However the comp.std.c++ group is moderated and I have no idea how long
it will take to be answered there. So, please, hold your fire. All C++ questions are welcome here, no fire to be expected.
Is there any special reason (performance, etc.) for using "(*i).second"
instead of "i->second"?



不,绝对不是。
6到7年前的b $ b,有些人说的是(*一世)。可能更便携

即i-> ,由于某些库

实现的不一致 - 但这是历史。

我认为今天没有理由选择(* i)。在i->

hth-Ivan

-
http://ivan.vecerina.com/contact/?subject=NG_POST < - 电子邮件联系表格


No, most certainly not.
6-7 years ago, some were saying that (*i). may be more portable
that i-> , because of the inconsistency of some library
implementations - but this is history.
I see no rationale today for preferring (*i). over i->
hth-Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form

brian写道:
大家好,

首先,我知道我的问题与STL有关。
然而comp。 std.c ++小组是主持的,我不知道如何在那里回答它需要多长时间。请你好好开火。

现在的问题是:

是否有任何特殊原因(表现等)使用
(* ⅰ)。第二"而不是i->秒?


不,只是个人喜好。

示例如下:

typedef std :: map< ...> table;

extern table t;
table :: iterator i;
for(i = t.begin(); i!= t.end(); i ++)
Hello all,

First of all I am aware of the fact that my question is STL related.
However the comp.std.c++ group is moderated and I have no idea how
long it will take to be answered there. So, please, hold your fire.

And now the question:

Is there any special reason (performance, etc.) for using
"(*i).second" instead of "i->second"?
No, just personal preference.

The example follows:

typedef std::map<...> table;

extern table t;
table::iterator i;
for (i=t.begin(); i!=t.end(); i++)




但是这里使用post增量会有性能上升。尽可能使用++ i



Jeff Flinn



But there is a performance hit here using post increment. Use ++i instead
whenever possible.

Jeff Flinn


2月18日星期五2005 13:18:24 +0100,Ivan Vecerina

< NO **************************** ******@vecerina.com>写道:
On Fri, 18 Feb 2005 13:18:24 +0100, Ivan Vecerina
<NO**********************************@vecerina.com > wrote:
" brian" <峰; br *********** @ yahoo.com>在消息中写道
新闻:11 ********************** @ z14g2000cwz.googlegr oups.com ...
"brian" <br***********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
首先,我知道我的问题与STL有关。
然而comp.std.c ++组被审核,我不知道在那里需要多长时间才能得到回答。那么,请你好好开火。
First of all I am aware of the fact that my question is STL related.
However the comp.std.c++ group is moderated and I have no idea how long
it will take to be answered there. So, please, hold your fire.


欢迎所有C ++问题,没有预料之火。


All C++ questions are welcome here, no fire to be expected.

是否有任何特殊原因(性能等) 。)使用(* i).second
而不是i-> second?
Is there any special reason (performance, etc.) for using "(*i).second"
instead of "i->second"?


不,绝对不是。
6-7岁有人说(* i)。可能更便携
i-> ,由于某些库实现的不一致 - 但这是历史。
我认为今天没有理由选择(* i)。在i->


No, most certainly not.
6-7 years ago, some were saying that (*i). may be more portable
that i-> , because of the inconsistency of some library
implementations - but this is history.
I see no rationale today for preferring (*i). over i->




啊,谢谢,我也记得听到过这个但不是为什么,我用了

- >在我的所有C ++代码中形成多年没有问题。


Chris C



Ah, thanks, I too remembered hearing about it but not why, I''ve used the
-> form in all of my C++ code for many years with no problems.

Chris C


这篇关于STL地图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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