list<>.size()

Michael Vance briareos@lokigames.com
Fri Mar 31 17:34:00 GMT 2000


On Fri, Mar 31, 2000 at 05:05:49PM -0800, Daniel Berlin wrote:

> AFAICT, no.

Bummer.

> Looking at the STL docs, I don't see size guaranteed to be O(1).

No, it is not mandated.

> guaranteed to be O(1) in complexity, i would strongly encourage your
> programs to stop assuming it is.

I port code for a living. I have no control over the original
developer's intelligence. But it seems this thing wouild be trivial to
implement and rectify an important porting issue. Changing every

while( list<>.size( ) ) {
       iterator is = list.begin( );
       delete *is;
       list<>.erase( is );
}

is tedious. As is changing every:

if( list<>.size( ) ) {
    // do blah
}

m.

-- 
Programmer             "Ha ha." "Ha ha." "What are you laughing at?"
Loki Software                      "Just the horror of being alive."
http://lokigames.com/~briareos/                   - Tony Millionaire


More information about the Gcc mailing list