Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

move elements from vector to unordered_set

#include <iostream>
#include <vector>
#include <unordered_set>
 
int main()
{
    std::vector<int> input({ 1, 2, 2, 1, 3, 1, 4 });
 
    std::unordered_set<int> set(input.begin(), input.end());
 
    for (const int &i: set) {
        std::cout << i << " ";
    }
 
    return 0;
}
Source by www.techiedelight.com #
 
PREVIOUS NEXT
Tagged: #move #elements #vector
ADD COMMENT
Topic
Name
2+6 =