C++ Insert iterator

Inserters 使算法以输入模式操作。
赋值:在容器中插入一个值
移动
三种inserters:
Back inserters:push_back()
#include
#include
#include
#include
#include
#include
#include

using namespace std;

int main()
{
	list coll1;
	for(int i=1;i<10;i++)
		coll1.push_back(i);

	copy(coll1.begin(), coll1.end(), ostream_iterator(cout, "\t"));

	vector coll2;
	copy(coll1.begin(), coll1.end(), back_inserter(coll2));
	cout<(cout, "\t"));

	deque coll3;
	copy(coll1.begin(), coll1.end(), front_inserter(coll3));
	cout<(cout, "\t"));

	set coll4;
	copy(coll1.begin(), coll1.end(), inserter(coll4, coll4.begin()));
	cout<(cout, "\t"));
	cout<


vector,deque,list,string
Front insterters: push_front()
deque,list,forward_list
General inserters: insert()

map, set



你可能感兴趣的:(C++)