-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy3.cpp
More file actions
41 lines (33 loc) · 767 Bytes
/
copy3.cpp
File metadata and controls
41 lines (33 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <algorithm>
using namespace std;
template<typename T>
void print_sequence(const T &t)
{
typename T::const_iterator pos;
for (pos = t.begin(); pos != t.end(); ++pos) {
cout << *pos << " ";
}
cout << endl;
}
int main(int argc, char *argv[])
{
list<int> col1;
for (int i=1 ; i < 9; ++i)
col1.push_back(i);
print_sequence(col1);
vector<int> col2;
copy(col1.begin(), col1.end(), back_inserter(col2));
print_sequence(col2);
deque<int> col3;
copy(col2.begin(), col2.end(), front_inserter(col3));
print_sequence(col3);
set<int> col4;
copy(col1.begin(), col1.end(), inserter(col4, col4.begin()));
print_sequence(col4);
return 0;
}