The complexity is a lie.

The complexity is a lie.
http://www.cplusplus.com/reference/list/list/size/

Comments

  1. Why do you think so? And are you talking about the C++11 case?

    ReplyDelete
  2. Yes. Apparently having a constant-time size function (and the structure changes that implied) broke so much binary compatibility that at least GCC has decided to revert to the linear-time size function. Some of my colleagues just got bit by that. I leave it as an exercise for the reader to implement both size() and splice() in constant time.

    ReplyDelete
  3. C++03 required ABI breakage for some implementors. So does C++11. If compatibility is more important, vendors must not claim that their implementation (fully) conforms to the standard.

    So what you are saying is not that the complexity claim in the standard is a lie. But that a specific implementation is still at pre-C++11 for this.

    Full-list and single-element splice are easily done in constant time, even when tracking size. Range splice is specified to be up to linear in the size of the range. Apparently the C++11 committee decided to favor constant size over constant splice.

    ReplyDelete

Post a Comment

Popular posts from this blog

If only the sun flares in my photos were this impressive.