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