|
From: Ioannis V. <iv...@em...> - 2003-07-14 16:22:43
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Hossein Haeri
> Sent: Monday, July 14, 2003 3:19 PM
> To: dev...@li...
> Subject: RE: [Dev-C++] STL Map question
>=20
>=20
> Had you read "Effective STL," this has't been your answer.=20
:-)
> Sometimes,
> there are policies such as willing to have a constant-time operation
> on the map that have higher proiority for the implementer (for any
> reason they know). And achieving that runtime needs you to cut down
> the use of size update after any operation of the map.
Not any operation, size() has to be updated during insert() or erase() =
only.
Also bool empty() const { return size()=3D=3D0; } takes constant time.
=20
> I think the existance of nasty C++ implementations such as VC++6,
> reveals that this is not just a fiction, and there even are wellknown
> implementations who may have chosen that way.
Anyway we are talking without any basis here, the implementor can choose
whatever method he likes to implement size() but if he calculated size()
everytime it was called (or only the first time if no other change has =
been
made) would be unwise since our code would wait for the internal loop of =
our
thousands record counting to complete.
In any case one would expect that the perofmrmance of size() in a if()
statement wouldn't take 10 seconds. TC++PL provides the above check as a
reasonable implementation I agree with it.
> You'r right. But max-performance of what? I mean, if there is an
> operation, say O, that has higher priority from your point of view (as
> the implementer, or disigner, etc.), and you want O to be done in a
> constant time, and that forces you to forget updating size after O,
> will you still think that max-performance obliges you to have size as
> an internal member?=20
There is not any Big-Oh requirement of the standard both regarding =
size() or
empty(). In theory empty() could be slower than size() (since there is =
not
any kind of restriction), but I said let's try to be realists.
> Haven't you ever encountered nasty
> implementations such as VC++6 that often have such higher priority
> operations that don't seem to be reasonable at all?
I used VC++ 6 only to what it is best for. To learn C90. :-) Regarding =
ISO
C++ it is crap. VC++ .NET 2002/2003 on the other hand are very good
regarding C++ compliance.
> I have just
> realised that the compiler we were talking about was GCC, and I=20
> hartapologise for the suspection I have had to his majesty. But
> remember that I didn't know that's GCC. Knowing that, don't you still
> preserve me the right of suspecting the implementation?
Well I would start suspecting if the code was crawling.
=20
> I agree with you in the sense of efficiency, but remember the problem
> with (sometimes unwanted) priorities.
>=20
> Furthermore, sometimes, the dicision of throwing a platform away is
> not whithin our duty. Nor can we complain on it. E.g., the project may
> be in a platform that is used for years and years, and changing it
> imposes more cost to the wendors. As an other example, you may be one
> of the ordinary programmers in more than 1000, in a software-house
> that wants its products to have good GUIs, and so have chosen VC++6 as
> they don't want to waste time for reinvnting the wheel! They may well
> know about the vast erea of VC++6's bugs, but they have to tollerate
> against it. So they are not going to change the platform. What would
> you do then?
Does VC++ 6 crawl whem map::size() is used?
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|