STL实施 [英] STL implmementation

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

问题描述

如果我错了,请纠正我,但是STL标准只定义了界面

而不是实现,对吗?


例如,说我使用std :: map。

运算符[](键)函数的速度和效率可能因库到库而异吗?例如,对于Linux来说,STL C ++库的一个实现可能会有所不同

(更慢,更快,更大的代码等)然后说STL C ++图书馆

Windows?


如果是这种情况,那么要在多平台应用程序中使用STL,它将会是b $ b最好坚持一个已经移植到多个平台的实现?


谢谢。


- -

Alvin

解决方案

Alvin于4月28日上午9:53写道

正确我,如果我错了,但STL标准只定义了
接口,而不是实现,对吗?
例如,假设我使用std :: map。
操作符[](键)功能的速度和效率可能因库到库而异吗?对于
示例,STL C ++库的一个实现,比如说Linux,可能会有所不同(更慢,更快,更大的代码等)
然后说STL C ++ Library for Windows?




试试这个页面: http://www.sgi.com/tech/stl/table_of_contents.html

,特别注意''复杂性保证''。


Abe


Alvin写道:

如果我错了,请纠正我,但仅限STL标准只定义了界面而不是实现,对吗?


不是实现本身,而是一些实现品质。

例如,假设我使用std :: map。
操作符[](键)功能的速度和效率可能因库到库而异吗?


它可能会有所不同,但不能低于要求。

[..]
如果是这种情况,那么在多平台应用程序中使用STL,最好坚持使用已经移植到多个平台的实现吗?




A第三方库是第三方库。一旦你把自己绑在了它上面,你就变得依赖了。它给你带来了什么?也许你在其他地方找不到的东西,也许什么都没有。


效率是应用程序的一个特征。它通常只取决于你使用*或者*谁*实现它,但也取决于*你如何使用

它。关于使用任何特定图书馆的决定必须以研究和比较为基础进行,并且不仅考虑使用它的成本

*现在*但是成本*继续*使用它或成本

*无法*继续使用它。


然而,当然,没有人能分辨你最好的是什么?为了你。而且,

什么对你最好的并不一定对每个人都是最好的。


V

Alvin写道:

如果我错了,请纠正我,但STL标准只定义了界面而不是实现,对吗?
种类。它对实现提出了要求。


例如,假设我使用std :: map。
操作符[](键)功能的速度和效率可能因库到库而异吗?例如,对于Linux来说,STL C ++库的一个实现可能是不同的(更慢,更快,更大的代码等)然后说Windows的STL C ++库?
每个STL容器和算法必须达到最低效率
。允许它们更有效。

请参阅: http ://www.sgi.com/tech/stl/


此外,STL的制造商或实施者将无法获得

很多东西都是邋or或低效的容器和算法。

这就是竞争的全部意义所在。当其他

实现者的表现更好时,没有人会因为糟糕的表现而支付
的钱。


无法比较效率考虑到底层硬件和操作系统,没有
的平台。

Windows在某些方面可能比Linux更有效,

其他不是''吨。多任务或多用户计算机

将无法将单个用户计算机专用于单个

任务。当我的CD音乐和Seti @ Home程序运行时,我的程序将运行得更慢

,而不是我没有。


在程序运行之前不要担心效率

正确。在网上搜索过早优化。


如果是这种情况,那么要在多平台应用程序中使用STL,它最好坚持使用实现已移植到多个平台?

谢谢。




使用STL的一些关键点:

1.这些东西已经写完了。

你不必浪费时间写一个链表或

a队列。


2.这些东西已经过测试。

你不必浪费时间调试算法

或容器。


为了更快地编写代码或生成更多代码,你需要写b / b
。研究第一。

-

Thomas Matthews


C ++新闻组欢迎辞:
http://www.slack.net/~shiva/welcome.txt
C ++常见问题: http://www.parashift.com/ c ++ - faq-lite

C常见问题: http://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn.c-c ++常见问题:
http://www.comeaucomputing.com/learn/faq /

其他网站:
http:// www.josuttis.com - C ++ STL图书馆书籍
http ://www.sgi.com/tech/stl - 标准模板库

Correct me if I am wrong, but the STL standard only defines the interface
only and not the implementation, right?

For example, say I use a std::map. The speed and efficiency of the
operator[](key) function can vary from library-to-library? For example, one
implementation of the STL C++ library, say for Linux, could be different
(slower, faster, larger code, etc.) then say the STL C++ Library for
Windows?

If this is the case, then to use the STL in a multiplatform application, it
would be best to stick with an implementation that has been ported to
multiple platforms?

Thanks.

--
Alvin

解决方案

Alvin wrote on Apr 28, 9:53 am

Correct me if I am wrong, but the STL standard only defines the
interface only and not the implementation, right? For example, say I use a std::map. The speed and efficiency of the
operator[](key) function can vary from library-to-library? For
example, one implementation of the STL C++ library, say for
Linux, could be different (slower, faster, larger code, etc.)
then say the STL C++ Library for Windows?



Try this page: http://www.sgi.com/tech/stl/table_of_contents.html
and look especially for ''Complexity guarantees''`.

Abe


Alvin wrote:

Correct me if I am wrong, but the STL standard only defines the interface
only and not the implementation, right?
Not the implementation itself, but some implementation qualities.
For example, say I use a std::map. The speed and efficiency of the
operator[](key) function can vary from library-to-library?
It can vary but it can''t be below the requirements.
[..]
If this is the case, then to use the STL in a multiplatform application, it
would be best to stick with an implementation that has been ported to
multiple platforms?



A third-party library is a third-party library. Once you tied yourself
to it, you become dependent. What does it buy you? Maybe something you
cannot find elsewhere, maybe nothing.

Efficiency is a characteristic of an application. It often depends not
only on *what* you use or *who* implemented it, but also on *how* you use
it. Decisions on the use of any particular library have to be made based
on research and comparison, and considering not only the cost of using it
*now* but the cost of *continuing* to use it or the cost in case of the
*inability* to continue to use it.

And, of course, nobody can tell you what''s "best" for you. And, also,
what''s best for you is not necessarily best for everybody.

V


Alvin wrote:

Correct me if I am wrong, but the STL standard only defines the interface
only and not the implementation, right? Kind of. It places requirements on the implementation.

For example, say I use a std::map. The speed and efficiency of the
operator[](key) function can vary from library-to-library? For example, one
implementation of the STL C++ library, say for Linux, could be different
(slower, faster, larger code, etc.) then say the STL C++ Library for
Windows? There is a minimum efficiency that each STL container and algorithm
must achieve. They are allowed to be more efficient.
See: http://www.sgi.com/tech/stl/

Also, manufacturer''s or implementors of the STL will not gain
much by having sloppy or inefficient containers and algorithms.
This is what competition is all about. Nobody is going to pay
money for poor performance when better performance by other
implementors exists.

One cannot compare efficiency across platforms without
considering the underlying hardware and operating system.
Windows may be more efficient than Linux in some areas,
others it isn''t. A multi-tasking or multi-user machine
will not be able to dedicate as many resources as a single
task, single user machine. My programs will run slower
when I have the CD Music and Seti@Home programs running
than if I don''t.

Don''t worry about efficiency until the program works
correctly. Search the web for "Premature Optimization".

If this is the case, then to use the STL in a multiplatform application, it
would be best to stick with an implementation that has been ported to
multiple platforms?

Thanks.



Some key points to using the STL:
1. The stuff is already written.
You don''t have to waste time writing a linked list or
a queue.

2. The stuff has been tested.
You don''t have to waste time debugging the algorithms
or containers.

In order to write code faster or produce more code, you
should write less code. Research first.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library


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

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