-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpushing_vector_into_set.cpp
More file actions
50 lines (39 loc) · 913 Bytes
/
Copy pathpushing_vector_into_set.cpp
File metadata and controls
50 lines (39 loc) · 913 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
42
43
44
45
46
47
48
49
50
/**
* Putting all elements from vectors to set
*/
#include <iostream>
#include <vector>
#include <set>
void printDataVector(std::vector <int>& vReceived) {
for (int i=0;i<vReceived.size(); ++i) {
std::cout << vReceived[i] << " " ;
}
std::cout << std::endl;
}
void printDataSet(std::set <int>& sObj ) {
for (const auto& i: sObj) {
std::cout << i << " ";
}
std::cout << std::endl;
}
inline void clearSTL (std::vector <int>& vReceived, std::set <int>& sObj) {
vReceived.clear();
sObj.clear();
}
int main()
{
std::vector <int> vObj {};
std::set <int> sObj {};
for (int i=0;i<5; ++i) {
vObj.push_back(i);
}
std::cout << std::endl;
printDataVector(vObj);
for (const auto& i :vObj ) {
sObj.insert(i);
}
std::cout << std::endl;
printDataSet(sObj);
clearSTL(vObj, sObj);
return (0);
}