stl:list:splice

C++ Reference

splice

Syntax:

    #include <list>
    void splice( iterator pos, list& lst );
    void splice( iterator pos, list& lst, iterator del );
    void splice( iterator pos, list& lst, iterator start, iterator end );

The splice function moves one or more items from lst right before location pos. The first overloading moves all items to lst, the second moves just the item at del, and the third moves all items in the range inclusive of start to just before end.

splice simply moves elements from one list to another, and doesn't actually do any copying or deleting. Because of this, splice runs in constant time except for the third overloading which needs no more than linear time in the case that lst is not the same as this. However, if size is linear complexity then splice is constant time for all three.

Related Topics: insert, merge, swap