ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.05k stars 437 forks source link

Remove duplicate elements from multiple input vectors at the same time #1801

Open dimy-x opened 7 months ago

dimy-x commented 7 months ago

Hello guys,

If we have the following input data vectors (same size dimension)

std::vector times = {1, 2, 1, 3, 4, 1, 2, 3, 4, 5}; std::vector doubles = {1.1, 2.1, 1.1001, 3.1, 4.1, 1.1, 2.1, 3.1, 4.1, 5.1}; std::vector values = {"s1", "s2", "s1s1", "s3", "s4", "s1", "s2", "s3", "s4", "s5"};

I want to modify the original three vectors by removing the duplicates. I consider that there is duplicate if times[n] = times[k] && doubles[n] = doubles[k]

Is there an elegant and effitient solution with the range-v3 library ?

Many thanks in advance, dimy-x