Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_index] looking for "equal_to and less than"
From: joaquin_at_[hidden]
Date: 2010-08-02 07:43:51


isjk escribió:
> hi,
>
> I've got a structure like this,
> struct peer
> {
> int md5_; // unique key.
> int rank_;
> int degrees_;
> };
>
> now, I need a composite_key, it can find equal_to "md5" and less than
> "rank_" and "degrees_" less than 8.
>

You can't directly do that with a composite key. There's two alternatives:

* Have your composite key defined on (md5_,rank_) (in this order),
do a lower_bound on (md5_value,rank_value), which gives you
the elements with md5_==md5_value and rank_<rank_value, and filter
those according to their degrees_ value.

* Have your composite key defined on (md5_,degrees_), do
a lower_bound on (md5_value,degrees_value), etc.

HTH,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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