|
From: Ioannis V. <iv...@em...> - 2003-07-14 18:51:59
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Hossein Haeri
> Sent: Monday, July 14, 2003 8:51 PM
> To: dev...@li...
> Subject: RE: [Dev-C++] STL Map question
>
> > :-)
>
> Sorry, but I can't view these cute faces because my mail server
> provides text only.
Man you are very new to the Net. :-)
> > Also bool empty() const { return size()==0; } takes constant time.
>
> Hmmm.... The only operation you have neglected is operator[].
Yes you are right.
> But there
> is another fine point. That is, when you are going to insert or erase
> only one element, it is extremely easy to update size, but
> when dealing
> with range counterparts, the story is not that easy.
I do not think that it would be so difficult (e.g. --size; for every item
erased, where size the internal representation of size, and without any
checks if size>0).
In any case, map<>::empty() is a right solution to check whether the map is
empty, so in reality we have been quibbling the details here.
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|