function for dealing with duplicates in an array

Feb 20, 2014 at 6:36am
--
Last edited on Feb 20, 2014 at 7:02pm
Feb 20, 2014 at 7:15am
std::unique
Feb 20, 2014 at 7:46am
I can't use anything from the algorithm library.
Feb 20, 2014 at 8:09am
And therefore you cannot read the reference documentation for std::unique, which does show one possible implementation for std::unique. If I would copy-paste it here, you could not read it, right?


You are looking at two consecutive items and end up in trouble. So don't.

What if you had a bucket 'src' and bucket 'dst'? You take one item from src. If it is the same as the top item in dst, then toss it away. Else place it in dst. Rinse and repeat until the src is empty.
Topic archived. No new replies allowed.