4 ms·
According to http://www.cplusplus.com/reference/list/list/size/ http://www.cplusplus.com/reference/list/list/size/, list::size must be constant time in C++11.
by Someone 13y ago
According to http://www.cplusplus.com/reference/list/list/size/ http://www.cplusplus.com/reference/list/list/size/, list::size must be constant time in C++11.
That may make 'splice' slower. See http://home.roadrunner.com/~hinnant/On_list_size.html http://home.roadrunner.com/~hinnant/On_list_size.html (I think that could be solved by having list iterators carry a field pointing to their container, but haven't given it much thought. Corrections welcome)
- deleted 13y ago[deleted]
- TwistedWave 13y agoHaving list iterators carry a field pointing to their container wouldn't help you determine the number of objects between two iterators when you splice, which is what you need in order to maintain the object count. Storing an index in the iterator would not be a solution either. That would mean updating the index in all the existing iterators when you insert an object in the list.
- Someone 13y agoOf course. Thanks.