1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
int main ()
{
// for non-predicate version of std::sort, point needs an operator <
// for non-predicate version of std::unique, point needs an operator ==
// for brevity, using a std::pair<> which has both
using point = std::pair<int,int> ;
std::vector< point > my_points { {2,4}, {5,4}, {2,4}, {0,1}, {5,4}, } ;
std::sort( my_points.begin(), my_points.end() ) ;
my_points.erase( std::unique( my_points.begin(), my_points.end() ), my_points.end() ) ;
for( point p : my_points ) std::cout << '(' << p.first << ',' << p.second << ") " ;
std::cout << '\n' ;
}
|