Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename Container>
- Container produce_unique(Container c){
- Container rtn;
- std::sort(c.begin(), c.end());
- std::unique_copy(c.begin(), c.end(), std::back_inserter(rtn));
- return rtn;
- }
- template<typename Container, typename T = typename Container::value_type>
- Container produce_unique2(const Container& c){
- Container rtn;
- std::unordered_set<T> st;
- std::copy_if(c.begin(), c.end(), std::back_inserter(rtn), [&st](const T& t){ return st.insert(t).second; });
- return rtn;
- }
Add Comment
Please, Sign In to add comment