名前空間
変種
操作

std::list::splice

提供: cppreference.com
< cpp‎ | container‎ | list

 
 
 
std::list
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::list
list::~list
list::operator=
list::assign
list::get_allocator
要素アクセスの循環参照を解除するために使用されている
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::front
list::back
イテレータ
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::begin
list::cbegin

(C++11)
list::end
list::cend

(C++11)
list::rbegin
list::crbegin

(C++11)
list::rend
list::crend

(C++11)
容量
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::empty
list::size
list::max_size
修飾子
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::clear
list::insert
list::emplace(C++11)
list::erase
list::push_front
list::emplace_front(C++11)
list::pop_front
list::push_back
list::emplace_back(C++11)
list::pop_back
list::resize
list::swap
操作
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
list::merge
list::splice
list::remove
list::remove_if
list::reverse
list::unique
list::sort
 
void splice(const_iterator pos, list& other);
(1)
void splice(const_iterator pos, list&& other);
(1) (C++11およびそれ以降)
void splice(const_iterator pos, list& other, const_iterator it);
(2)
void splice(const_iterator pos, list&& other, const_iterator it);
(2) (C++11およびそれ以降)
void splice(const_iterator pos, list& other,
            const_iterator first, const_iterator last);
(3)
void splice(const_iterator pos, list&& other,
            const_iterator first, const_iterator last);
(3) (C++11およびそれ以降)
つのリストから別の要素を移動.
Original:
Moves elements from one list to another.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
何も要素はコピーされません。 get_allocator() != other.get_allocator():場合の動作は未定義です。無効になるんイテレータや参照は、移動した要素へのイテレータは今ではない*thisに、otherに参照していない.
Original:
No elements are copied. 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.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
other*thisからすべての要素を移動します。要素はposが指す要素の前に挿入されます。コンテナotherは術後空になります。 this == &other場合の動作は未定義です.
Original:
Moves all elements from other into *this. The elements are inserted before the element pointed to by pos. The container other becomes empty after the operation. The behavior is undefined if this == &other.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
要素はitからother*thisによって指さ移動します。要素がposが指す前に要素が挿入され.
Original:
Moves the element pointed to by it from other into *this. The element is inserted before the element pointed to by pos.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
[first, last)otherから*thisに範囲内の要素を移動します。要素はposが指す要素の前に挿入されます。 posが範囲[first,last)でイテレータの場合の動作は未定義です.
Original:
Moves the elements in the range [first, last) from other into *this. The elements are inserted before the element pointed to by pos. The behavior is undefined if pos is an iterator in the range [first,last).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

pos -
コンテンツが挿入される前に、要素
Original:
element before which the content will be inserted
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
other -
からコンテンツを移動するための別のコンテナ
Original:
another container to move the content from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
it -
otherから*thisに移動する要素
Original:
the element to move from other to *this
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
first, last -
otherから*thisに移動する要素の範囲
Original:
the range of elements to move from other to *this
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

(なし)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 複雑

1-2)
定数.
Original:
Constant.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
一定の場合this == &otherでそうでなければリニアstd::distance(first, last)、.
Original:
Constant if this == &other, otherwise linear in std::distance(first, last).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <list>
 
std::ostream& operator<<(std::ostream& ostr, const std::list<int>& list)
{
    for (auto &i : list) {
        ostr << " " << i;
    }
    return ostr;
}
 
int main ()
{
    std::list<int> list1 = { 1, 2, 3, 4, 5 };
    std::list<int> list2 = { 10, 20, 30, 40, 50 };
 
    auto it = list1.begin();
    std::advance(it, 2);
 
    list1.splice(it, list2);
 
    std::cout << "list1: " << list1 << "\n";
    std::cout << "list2: " << list2 << "\n";
 
    list2.splice(list2.begin(), list1, it, list1.end());
 
    std::cout << "list1: " << list1 << "\n";
    std::cout << "list2: " << list2 << "\n";
}

Output:

list1:  1 2 10 20 30 40 50 3 4 5
list2: 
list1:  1 2 10 20 30 40 50
list2:  3 4 5

[編集] も参照してください

2ソートされたリストをマージします
Original:
merges two sorted lists
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
特定の条件を満たす要素を削除します
Original:
removes elements satisfying specific criteria
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]