splice [C++ Reference]
Keywords: stl,list,splice
Date: 2009-08-02T22:36:52-0700

[[splice]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## 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` and exclusive of `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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •