Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-index] retrieve unique keys of a non-unique index
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2013-08-02 04:05:06


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