list<>.size()
Tudor Hulubei
tudor.hulubei@ecora.com
Fri Mar 31 17:46:00 GMT 2000
On Friday, 31 March 2000, Michael Vance wrote:
> 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.
What makes you think it is trivial to implement?
Think about splice:
void splice(iterator position, list<T, Alloc>& x, iterator f, iterator l);
This is the corresponding documentation from the STL library:
---
position must be a valid iterator in *this, and [first, last) must be
a valid range in x. position may not be an iterator in the range
[first, last). Splice moves the elements in [first, last) from x to
*this, inserting them before position. All iterators remain valid,
including iterators that point to elements of x. [3] This function is
constant time.
---
Since splice must be O(1), you can't count the elements you move from
one list to another, and therefore it is not possible to keep count of
the elements in the target list.
Do you have any idea how the Microsoft implementation works so that it
achieves O(1) for list<>.size()?
Tudor
More information about the Gcc
mailing list