使用吨stl一个正确的方法? [英] is using tons of stl a correct method?

查看:64
本文介绍了使用吨stl一个正确的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个项目中,我使用了很多很多stl,比如堆栈,列表,vctor等。


某处矢量'的大小超过2K。这是一种有效的方法吗?

in a project, I use many,many stl such as stack,list,vctor etc.

somewhere the vector''s size is more than 2K. is this a efficient way?

推荐答案

rokia写道:
rokia wrote:
在一个项目中,我用了很多,很多stl,如stack,list,vctor等。

某处矢量'的大小超过2K。这是一种有效的方法吗?
in a project, I use many,many stl such as stack,list,vctor etc.

somewhere the vector''s size is more than 2K. is this a efficient way?




图书馆事物的低级细节,并冒风险错误你重新发明。使用STL容器使得C ++在认知上非常有效,因为它们具有高级能力。语言。


-

Phlip
http://industrialxp.org/community/bi...UserInterfaces




Using robust Standard Library gizmos is infinitely more efficient, in terms
of programming time, than using raw arrays, linked lists, ''new'', etc. If you
use those, you will endlessly reinvent low-level details that Standard
Library things, and risk bugs as you reinvent. Using STL containers makes
C++ as cognitively efficient as a "high-level" language.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces



是的,我同意。我最近能够专门使用STL而不是C-array和家庭自制d / s
,我很少崩溃和

干净起来是轻而易举的 - 它为我完成了!谢谢亚历克斯·斯捷潘诺夫,你们这个男人!!


" Phlip" < pH值******* @ yahoo.com>在消息中写道

新闻:NT ***************** @ newssvr31.news.prodigy.co m ...
Yes, I concur. I''ve recently been able to use STL exclusively rather
than C-arrays and home-brewed d/s, I''ve had very few crashes and
clean up is a breeze - its done for me! Thank you Alex Stepanov, you da
man!!

"Phlip" <ph*******@yahoo.com> wrote in message
news:NT*****************@newssvr31.news.prodigy.co m...
rokia写道:
rokia wrote:
在一个项目中,我使用很多很多stl,比如堆栈,列表,vctor等。

某处矢量'的大小超过2K。这是一种有效的方式吗?
使用健壮的标准库小玩意在编程时间方面比使用原始数组,链接列表,新更有效率,
in a project, I use many,many stl such as stack,list,vctor etc.

somewhere the vector''s size is more than 2K. is this a efficient way?
Using robust Standard Library gizmos is infinitely more efficient, in


'等等。如果您使用这些
,您将无休止地重新发明标准库事物的低级细节,并在您重新发明时冒险。使用STL容器使得C ++在认知上与高级别一样高效。语言。

-
Phlip
http://industrialxp.org/community/bi...UserInterfaces



感谢您的支持回复。


另一个问题:


当你有一个班级A.你会把A推回到列表吗?或者只是A的

指针?


我的意思是下面哪一个是正确的:


1: A类;

list< A> la;

A a,b,c;

la.push_back(a); la.push_back(b),la.push_back(c);


2:A类;

list< A *> la;

A * pa;

A * pb;

A * pc;

la.push_back( pa); la.push_back(pb); la.push_back(pc);


我应该使用哪种方法如果有5000个A级或更多?


谢谢。:)

thanks for your reply.

another question:

when you have a class A. will you push_back A to a list? or just the
pointer of A?

I mean which is the right one below:

1: class A;
list<A> la;
A a,b,c;
la.push_back(a); la.push_back(b),la.push_back(c);

2:class A;
list<A*> la;
A *pa;
A *pb;
A *pc;
la.push_back(pa);la.push_back(pb);la.push_back(pc) ;

and which method should I use If THERE ARE 5000 class A OR MORE?

thanks.:)


这篇关于使用吨stl一个正确的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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