Topic: Mandated overhead
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1998/07/03 Raw View
jkanze@otelo.ibmmail.com wrote:
>
> In article <6nbr2c$j10$1@shell7.ba.best.com>,
> ncm@nospam.cantrip.org (Nathan Myers) wrote:
>
> > The fact is, the standard does not mandate overhead.
>
> The fact is that the complexity requirements in the standard library
> do mandate some specific choices with regards to the space/time tradeoff.
> To obtain ammortised constant time for vector<T>::push_back, it is
> necessary to overallocate, for example.
If you work on an embeded system, you certainly have time
to optimize the memory usage. This time is best used by calling
reserve (trivial) than by reinventing wheels (long, tedious,
and great potential for bugs).
--
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: jkanze@otelo.ibmmail.com
Date: 1998/07/01 Raw View
In article <6nbr2c$j10$1@shell7.ba.best.com>,
ncm@nospam.cantrip.org (Nathan Myers) wrote:
> The fact is, the standard does not mandate overhead.
The fact is that the complexity requirements in the standard library
do mandate some specific choices with regards to the space/time tradeoff.
To obtain ammortised constant time for vector<T>::push_back, it is
necessary to overallocate, for example.
This preference for improving run-time at the cost of memory usage is
pervasive in the standard library. On the whole, I don't disagree with
this decision. But it does mean that the standard vector class is
generally not appropriate for memory tight systems.
--
James Kanze +33 (0)1 39 23 84 71 mailto: kanze@gabi-soft.fr
+49 (0)69 66 45 33 10 mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orientee objet --
-- Beratung in objektorientierter Datenverarbeitung
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Mike Davies <mike_davies@noco.demon.co.uk>
Date: 1998/07/02 Raw View
In article <6ndm0o$ddf$1@nnrp1.dejanews.com>, jkanze@otelo.ibmmail.com
writes
>In article <6nbr2c$j10$1@shell7.ba.best.com>,
> ncm@nospam.cantrip.org (Nathan Myers) wrote:
>
>> The fact is, the standard does not mandate overhead.
>
>The fact is that the complexity requirements in the standard library
>do mandate some specific choices with regards to the space/time tradeoff.
>To obtain ammortised constant time for vector<T>::push_back, it is
>necessary to overallocate, for example.
That is not an overhead.
That is a cost for using the vector<T> class. It would also be a cost (a
time cost in this case) to have a lazy allocation strategy.
There are costs involved in *any* implementation of a vector-like
container (eg C-style arrays have *enormous* array extension costs).
The C++ standard committee chose the costs for the classes mandated by
the standard. If they are not suitable for a given application, then
don't construct an instance of one in that application.
You will find your code/data space requirements to be the same if you
include the STL headers without using the classed defined within as they
were before you included the headers. So it is a cost not an overhead.
>This preference for improving run-time at the cost of memory usage is
>pervasive in the standard library. On the whole, I don't disagree with
>this decision. But it does mean that the standard vector class is
>generally not appropriate for memory tight systems.
You don't quantify the memory cost you aver to be *mandated* by the
vector<T> class, so your statement is meaningless.
--
Mike Davies
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]