list::splice (STL/CLR)
Restitch 節點之間的連結。
void splice(iterator where, list<Value>% right);
void splice(iterator where, list<Value>% right,
iterator first);
void splice(iterator where, list<Value>% right,
iterator first, iterator last);
參數
第一個
要連接的範圍的開頭。last
要連接的範圍的結尾。right
要從中分離的容器。where
要連接之前的容器中的位置。
備註
第一個成員函式插入順序由控制right中所指的受控制序列的項目之前where。 它也會移除所有的項目,從right。 (%right must not equal this.)您可以用它來一份清單的所有連接到另一個。
第二個成員函式中移除項目所指向first所控制的序列中right ,並將它插入之前所受控制序列中的項目指向where。 (If where == first || where == ++first, no change occurs.)您可以用它來連接到其他的一份清單的單一項目。
第三個成員函式插入所指定的子範圍[first, last)所控制的序列中right中所指的受控制序列的項目之前where。 它也會移除原來的子範圍所控制的順序right。 (If right == this, the range [first, last) must not include the element pointed to by where.)您可以用它來連接到另一份清單中的零或多個項目目的序列。
範例
// cliext_list_splice.cpp
// compile with: /clr
#include <cliext/list>
int main()
{
cliext::list<wchar_t> c1;
c1.push_back(L'a');
c1.push_back(L'b');
c1.push_back(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// splice to a new list
cliext::list<wchar_t> c2;
c2.splice(c2.begin(), c1);
System::Console::WriteLine("c1.size() = {0}", c1.size());
for each (wchar_t elem in c2)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// return one element
c1.splice(c1.end(), c2, c2.begin());
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
for each (wchar_t elem in c2)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// return remaining elements
c1.splice(c1.begin(), c2, c2.begin(), c2.end());
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
System::Console::WriteLine("c2.size() = {0}", c2.size());
return (0);
}
需求
標頭: < cliext/清單 >
Namespace: cliext