Logo

Programming-Idioms

History of Idiom 118 > diff from v26 to v27

Edit summary for version 27 by fantasy:
New Cpp implementation by user [fantasy]

Version 26

2017-08-21, 19:39:54

Version 27

2018-05-08, 01:41:28

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Illustration

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Illustration
Imports
#include<unordered_set>
Code
std::unordered_set<T> y (x.begin (), x.end ());
Comments bubble
Assuming that x is a list of T's and T is hashable.