Boost logo

Boost Users :

Subject: Re: [Boost-users] best way to remove duplicates from forwardIterator [startIter, endIter]
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-02-26 11:15:28


On Thu, Feb 26, 2009 at 5:05 AM, Ovanes Markarian
<om_boost_at_[hidden]> wrote:
>
>
> On Tue, Feb 24, 2009 at 5:46 PM, Sandeep Gupta <gupta.sandeep_at_[hidden]>
> 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.
>
>
> Hi!
>
> I thought a bit about this issue. If you would like to use an algorithm to
> just make your code more descriptive, you still can achieve it by using
> typedef.
>
> typedef std::set<std::iterator_traits<IterType>::value_type>
> make_unique_elements;
>
> make_unique_elements uniques_(startIter, endIter);
>
>
> Hope that helps,
>
> Ovanes
>
>

Thanks Ovanes,
This would be better that what i have currently. However the bigger
problem was to avoid explicitly creating storage. As Dave mentioned if
sort was supported over forward iterators (and not bidirectional
iterators) then duplicate removal could have been expressed more
directly.
-sandeep

> _______________________________________________
> 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