std::forward_list::splice_after
来自cppreference.com
< cpp | container | forward list
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
void splice_after(const_iterator pos, forward_list& other); |
(1) | (C++11 起) |
void splice_after(const_iterator pos, forward_list&& other); |
(1) | (C++11 起) |
void splice_after(const_iterator pos, forward_list& other, const_iterator it); |
(2) | (C++11 起) |
void splice_after(const_iterator pos, forward_list&& other, const_iterator it); |
(2) | (C++11 起) |
void splice_after(const_iterator pos, forward_list& other, const_iterator first, const_iterator last); |
(3) | (C++11 起) |
void splice_after(const_iterator pos, forward_list&& other, const_iterator first, const_iterator last); |
(3) | (C++11 起) |
移动元素从另一个
forward_list
*this.原文:
Moves elements from another
forward_list
to *this.没有这样的元素复制。
1) pos
的有效迭代器*this是before_begin()迭代器的。的行为是不确定的,如果get_allocator() != other.get_allocator()。没有迭代器或引用变得无效,移动元素的迭代器是指到*this,不进other
.原文:
No elements are copied.
pos
is a valid iterator in *this or is the before_begin() iterator. The behavior is undefined if get_allocator() != other.get_allocator(). No iterators or references become invalidated, the iterators to moved elements now refer into *this, not into other
.将所有的元素
2) other
*this。后pos
所指向的元素,这些元素被插入。在手术后变成空容器other
。的行为是不确定的,如果this == &other原文:
Moves all elements from
other
into *this. The elements are inserted after the element pointed to by pos
. The container other
becomes empty after the operation. The behavior is undefined if this == &other移动元素所指向的
3) it
从other
到*this。后pos
所指向的元素,该元素被插入.原文:
Moves the element pointed to by
it
from other
into *this. The element is inserted after the element pointed to by pos
.(first, last)
从other
到*this移动的范围中的元素。后pos
所指向的元素,这些元素被插入。元素指出的first
不会移动。 pos
是不确定的,如果是一个迭代的范围内(first,last)
的行为.原文:
Moves the elements in the range
(first, last)
from other
into *this. The elements are inserted after the element pointed to by pos
. The element pointed-to by first
is not moved. The behavior is undefined if pos
is an iterator in the range (first,last)
.目录 |
[编辑] 参数
pos | - | 元素之后的内容将被插入
原文: element after which the content will be inserted |
other | - | 另一个容器中的内容移动
原文: another container to move the content from |
it | - | 从
other *this的元素原文: the element to move from other to *this |
first, last | - | 从
other *this的元素范围原文: the range of elements to move from other to *this |
[编辑] 返回值
(无)
[编辑] 复杂性
1)线性的大小
2) other
常数
3) 线性std::distance(first, last)
[编辑] 为例
演示的含义开区间(第一,最后)中的第三种形式splice_after():L1的第一个元素没有移动.
原文:
Demonstrates the meaning of open interval (first, last) in the third form of splice_after(): the first element of l1 is not moved.
#include <iostream> #include <forward_list> int main() { std::forward_list<int> l1 = {1,2,3,4,5}; std::forward_list<int> l2 = {10,11,12}; l2.splice_after(l2.cbegin(), l1, l1.cbegin(), l1.cend()); // not equivalent to l2.splice_after(l2.cbegin(), l1); for(int n : l1) std::cout << n << ' '; std::cout << '\n'; for(int n : l2) std::cout << n << ' '; std::cout << '\n'; }
输出:
1 10 2 3 4 5 11 12
[编辑] 另请参阅
合并两个已排序列表 (公共成员函数) | |
删除元素满足特定条件 原文: removes elements satisfying specific criteria (公共成员函数) |