Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] Defining a predicate for std::find_if if the key to a std::map is std::pair
From: Nat Goodspeed (nat_at_[hidden])
Date: 2009-09-24 21:38:55


Ryan wrote:

> On Thu, Sep 24, 2009 at 11:38 AM, Anthony Foglia <AFoglia_at_[hidden]
> <mailto:AFoglia_at_[hidden]>> wrote:
>
> Or, even easier, make the key just the string and the value a pair
> of the int and the vector of classA:
>
>
>
> On Thu, Sep 24, 2009 at 12:01 PM, Nat Goodspeed <nat_at_[hidden]
> <mailto:nat_at_[hidden]>> wrote:
>
> Yes, that's what I was thinking: migrate the int from the key to the
> mapped_type.
>
>
> This would indeed make the insert easier at the cost of complicating the
> retrieval. By making the int part of the key the retrieval is trival
>
> m_VariableDestinations.find(std::make_pair(name, intValue));
>
> If I was to move the int out of the pair I found that it increased the
> difficulty quite a bit.

My other thought is: have you looked at all at Boost Multi-Index?
http://www.boost.org/doc/libs/1_40_0/libs/multi_index/doc/index.html

It may be that your dual key requirements would best be met by dual indexes.


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