Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-index] retrieve unique keys of a non-unique index
From: Rory McCarthy (rorymccarthy77_at_[hidden])
Date: 2013-08-02 17:17:36


Thanks for the suggestions. I'm expecting that there will be relatively few
unique name keys, so using ordered_non_unique with O(m*log(n)) complexity
will definitely be more efficient,

On Fri, Aug 2, 2013 at 1:05 AM, Dominique Devienne <ddevienne_at_[hidden]>wrote:

> On Fri, Aug 2, 2013 at 9:36 AM, Joaquín Mª López Muñoz <joaquin_at_[hidden]>wrote:
>
>> std::unique_copy(
>> get<name>(taggedNodes).begin(),get<name>(taggedNodes).end(),
>> boost::make_function_output_iterator(&dump_entry_name),
>> equal_entry_name);
>> This is O(n), n being the number of total elements.
>>
>
> Ah yes, entries are clustered by keys during iteration whether ordered or
> hashed, I now realize. Thanks.
>
> Here's my STL-challenged version using BOOST_FOREACH. Less generic of
> course, but hopefully not buggy. --DD
>
> if (!get<name>(taggedNodes).empty()) {
> int curr_key = get<name>(taggedNodes).begin()->name;
> std::cout << curr_key << std::endl;
> BOOST_FOREACH (const TaggedNodeEntry& x, get<name>(taggedNodes)) {
> if (x.name != curr_key) {
> curr_key = x.name;
> std::cout << curr_key << std::endl;
> }
> }
> }
>
>
> _______________________________________________
> 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