This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: list<>.size()
- To: Michael Vance <briareos at lokigames dot com>
- Subject: Re: list<>.size()
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: Fri, 31 Mar 2000 17:05:49 -0800 (PST)
- cc: gcc at gcc dot gnu dot org
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