list<>.size()
Daniel Berlin
dan@cgsoftware.com
Fri Mar 31 17:08:00 GMT 2000
On Fri, 31 Mar 2000, Michael Vance wrote:
> Folks,
>
> Is list<>.size() O(1) for libstdc++ v3?
AFAICT, no.
> I bring this up because it's
> becoming a portability problem for us--on Windows list<>.size is O(1),
> so developers will oftentimes write loops with repeated tests against
> it. This becomes a speed nightmare when we port these to Linux.
>
Looking at the STL docs, I don't see size guaranteed to be O(1).
> If is not O(1) in libstdc++ v3, I would like to strongly encourage
> that it become so :).
I don't have the standard in front of me, but if list.size() isn't
guaranteed to be O(1) in complexity, i would strongly encourage your
programs to stop assuming it is.
>
> Regards,
>
> m.
--Dan
More information about the Gcc
mailing list