|
Boost Users : |
Subject: Re: [Boost-users] [boost] best way to remove duplicates from forwardIterator [startIter, endIter]
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-02-24 12:39:09
Hi Dave,
So i will stick with set solution. Its very kind of you reply
promptly. Appreciate it and thanks so much.
- sandeep
On Tue, Feb 24, 2009 at 9:22 AM, David Abrahams <dave_at_[hidden]> wrote:
>
> on Tue Feb 24 2009, Sandeep Gupta <gupta.sandeep-AT-gmail.com> wrote:
>
>> Hi,
>> Given a collection in terms of [startIter, endIter] how can obtain
>> [uniqBeginIter, uniqEndIter] that represents unique elements of the
>> original container.
>> I can always explicitly instantiate a set S of [startIter, endIter]
>> and use [S.begin(), S.end()]. Is it possible to express this in terms
>> of algorithms.
>>
>> Please note that I won't be able to use std::sort as startIter does
>> not conform to RandomAccessIterator. Its a forward iterator.
>
> If they are not already arranged so that all the equal elements are
> adjacent to one another, your best bet is set<> (or unordered_set<>).
>
> FWIW, It is possible to write a conforming std::sort that works on
> forward iterators, but for some reason the standard only requires sort
> to work on random access iterators.
>
> --
> Dave Abrahams
> BoostPro Computing
> http://www.boostpro.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net