On Mon, 21 Jun 1999, Eugene L. Berman wrote:
> Sorry for probably FAQ, but, anyway, what is the most standart
> C++ collections library (which contains classes like Vector,
> HashMap, Iterator, etc), and is best for use in Linux apps
> development?
Note: using STL has the following problems that you ought to be aware of
before starting to use it in anything but experimental code:
1. STL uses many templates, and thus would yield initially MANY odd
linking problems (that is, after you got over the compilation problems)
about missing symbols with very very long names.
on the good side - once you learn how to get ov\er these problems, STL
tends to cause very few runtime problems (which is the idea behind the
very strong typing of C++).
2. STL does NOT contain simple hash tables (and thus does not contain
HashMap, HashSet and the like). It does contain 'set' and 'map',
thought. the problem with map - it also orders its data, so is O(logN)
on insertions, instead of O(1) for a real hash table (provided a good
hashing function is used...).
_some_ STL implementations also contain the HashMap and HashSet
classes, but these are not standard, and won't necessarily exist in all
STL implementations.
3. STL itself (that is, at its source-code level) is NOT portable (today
at least) between different compilers, and thus if ytou move to another
compiler, you might need to move to a different STL implementation.
your source will mostly still compile, but it might be that you'll
encounter new bugs with the new STL implementation, etc.
note also that althought STL has been standardiszed, not all compilers
support its required C++ features up to the same level, and thus STL
with different compilers may require code modifications (e.g. according
to the standard, STL is now part of the 'std' name space. however, some
compilers do not support name spaces yet, so you'll need to use the STL
symbols without the 'std::' prefix).
4. because STL uses many templates, and because many compilers have rather
bad support for templates, the resulting binary files might become very
large. it is especially UNN wise to use gcc v2.7.x with STL for code
that uses many container types - the code might get bloated beyond the
capabilities of your machine.
5. STL has some large overhead when using many small containers (althought
the overhead for large containers seems to be rather small). In such
cases, it is better to revert to 'home-made' solutions, such as using a
STL collection containing simple vectors, etc. otherwise, the memory
requirements of your program might grow beyond your machine's
capabilities.
after setting up these points, and making yourself familiar with them, i
still would recommend usage of STL containers - provided it's done with
some care - not using too many container types in your program - in many
occasions, keeping small ammounts of data in simple arrays would be much
wiser.
also, whenever you use an STL container, typedef it, and use that typedef
only. this will make porting the code to other compilers/platforms/stl
implementations much easier.
one last note - try to avoid usage of STL's string class at almost any
cost - some of its implementations might be buggy (e.g. roguewave's STL),
and it does not necesarily handle strings with reference copunting, so
might lead to very unefficient code.
if you need any more info, please mail me directly.
hope this helps a bit(set??)
guy
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]