Boost logo

Boost Users :

Subject: Re: [Boost-users] boost multi-index container find method.
From: Ramesh (rramesh1_at_[hidden])
Date: 2009-09-17 15:29:13


Thank you very much.

On Thu, Sep 17, 2009 at 12:25 PM, Joaquin M Lopez Munoz <joaquin_at_[hidden]> wrote:
> Ramesh <rramesh1 <at> gmail.com> writes:
>
>>
>> Hello Joaquin,
>
> Hi Ramesh,
>
>> I have a class like below that uses mult-index container's find
>> method.  I have a record pattern as below initially:
>>
>> Idx : 100 Flag : 5
>> Idx : 200 Flag : 5
>> Idx : 300 Flag : 5
>> Idx : 400 Flag : 5
>>
> [...]
>>
>> Idx : 200 flag : 5
>>
>> While find functionally is correct in picking up the correct data, but
>> I am wondering why it doesnt pick the first record (100) which has the
>> flag value set to 5?
>
> find() returns an element with the searched key
> in case there is one, but note that no guarantee is made
> about which element is returned when there are several
> to choose from (in case you're curious: ordered indices
> are internally implemented as rd-trees, and find simply
> returns the first element found when traversing the
> tree topdown).
>
> Even if you use lower_bound() to find the first element
> of the range, there is no guarantee that (100,5) appears
> the first on the flag-based index. You can follow Igor's
> advice on using a composite key here.
>
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
>
> _______________________________________________
> 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