Inserting an Iterator Range into a Set

Revision en5, by Asliddin2010, 2024-12-16 13:24:48

// C++ program to insert elements in set using iterator range

include <bits/stdc++.h>
using namespace std;

int main(){
vector v{ 10, 20, 30 };
// Create an empty set
set s;

// Inserting values of vector to set                                                                                                                     
s.insert(v.begin(), v.end());

// Printing the set
for (int x : s) {
    cout << x << " ";
}
// Output: 10 20 30

return 0;

}

Tags set, insert, interator range

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en10 English Asliddin2010 2024-12-16 13:31:04 0 (published)
en9 English Asliddin2010 2024-12-16 13:30:50 1019
en8 English Asliddin2010 2024-12-16 13:29:27 3711 For those who didn't know, if you know, just a revision :)
en7 English Asliddin2010 2024-12-16 13:26:24 2498
en6 English Asliddin2010 2024-12-16 13:25:41 461
en5 English Asliddin2010 2024-12-16 13:24:48 1942
en4 English Asliddin2010 2024-12-16 13:23:19 4 Tiny change: 'or Range\ninclude ' -> 'or Range\n\n\ninclude '
en3 English Asliddin2010 2024-12-16 13:22:03 17
en2 English Asliddin2010 2024-12-16 13:18:58 41 For those who didn't know, if you know, just a revision :)
en1 English Asliddin2010 2024-12-16 13:16:21 463 For those who didn't know, if you know, just a revision :) (saved to drafts)