iota
시작 값을 사용 하 여 첫 번째 요소부터 시작 하 고 연속적으로 증가 시키면 해당 값을 채워 저장 (_Value++)에서 각 요소의 간격에서 [_First, _Last).
template<class ForwardIterator, class Type>
void iota(
ForwardIterator _First,
ForwardIterator _Last,
Type _Value
);
매개 변수
_First
채울 범위에서 첫 번째 요소가 설명 하는 입력된 반복기입니다._Last
채우려는 범위의 마지막 요소 주소 입력된 반복기입니다._Value
첫 번째 요소에서와 후속 요소를 연속적으로 증가 시킬 저장 시작 값입니다.
예제
일부 사용에 대 한 다음 예제는 iota 함수를 작성 하 여는 목록 정수 및 다음 채우기는 벡터 와 list 되도록는 스택으로의 함수를 사용할 수 있습니다.
// compile by using: cl /EHsc /nologo /W4 /MTd
#include <algorithm>
#include <numeric>
#include <list>
#include <vector>
#include <iostream>
using namespace std;
int main(void)
{
list <int> intList(10);
vector <list<int>::iterator> intVec(intList.size());
// Fill the list
iota(intList.begin(), intList.end(), 0);
// Fill the vector with the list so we can shuffle it
iota(intVec.begin(), intVec.end(), intList.begin());
random_shuffle(intVec.begin(), intVec.end());
// Output results
cout << "Contents of the integer list: " << endl;
for (auto i: intList) {
cout << i << ' ';
}
cout << endl << endl;
cout << "Contents of the integer list, shuffled by using a vector: " << endl;
for (auto i: intVec) {
cout << *i << ' ';
}
cout << endl;
}
Output
Contents of the integer list:
0 1 2 3 4 5 6 7 8 9
Contents of the integer list, shuffled by using a vector:
8 1 9 2 0 5 7 3 4 6
요구 사항
헤더: <numeric>
네임 스페이스: std