[ ... ]
What is it I'm missing here? AFAIK size() returns the number of elements
stored in the container, thus one could easily implement it with a
variable containing the value which is updated whenever an element is
inserted/removed from the container. How does that affect the time it
takes to splice two lists, all you have to do is add the size of both of
them.
If you splice one entire list onto another, it's no
problem at all. The problem arises when/if you grab only
_part_ of one list and splice it onto another. You can do
this by manipulating only the pointers in a couple of
nodes (the two that get spliced so they're next to each
other). Figuring out the size of the new list, however,
isn't quite so simple -- just about the only way to know
how many nodes you've added is to walk the list to count
the nodes.
You also run into a problem of how to maintain that
count. Consider (for example) two iterators into the list
that are both active at once. We insert some new nodes
into the list with one, but at the same time we're using
the other to splice part of the list onto a different
list. Now, if the code handling the first iterator
assumes it needs to update the count of items in the list
when it adds some nodes, it doesn't realize that the
nodes are now being added to a different list. It
attempts to update the count for the original list, and
now the counts for both the lists are wrong...