set<->list

Haskell

Public Domain

Convert a list to a set and vice versa

Download (right click, save as, rename as appropriate)

Embed

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include <list>
#include <set>
using namespace std;

template<typename T> set<T> list2set(const list<T>& stuff) {
 return set<T>(stuff.begin(), stuff.end());
}

template<typename T> list<T> set2list(const set<T>& stuff) {
 return list<T>(stuff.begin(), stuff.end());
}