
9 Dec
2006
9 Dec
'06
7:30 p.m.
me22 wrote:
I'm fairly certain that this does not need to be the case.
There was a thread a while back about going though the sources to look for uses of list::size exactly because it could be O(n) to ensure that there was always an O(1) empty-using function as an alternative to size.
I thought containers were only supposed to provide operations if those were efficient. If std::list::size is linear, then it shouldn't have been provided and std::count should have been used instead. I do not have the time to check the spec though, so I'll believe you if you say it's not guaranteed to be O(1).