* Computer Science/C++

c++ list splice

soicem 2018. 11. 1. 12:28

 iterator로 지정된 구간을 첫 파라미터의 위치로 옮기는 작업


1
2
3
4
5
6
7
8
9
10
11
12
13
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    list <int>  LLa = { 114115116117119120130140150 } ;
    list <int>::iterator it1, it2;
    it1 = LLa.begin() ; it1++ ;  it1++ ;  it1++ ;  it1++ ;
    it2 = it1; it2++; it2++; it2++;
    LLa.splice(LLa.end(), LLa, it1, it2) ;
    return 0;
}
 
 
cs