Thank you very much.
On Thu, Sep 17, 2009 at 12:25 PM, Joaquin M Lopez Munoz
Ramesh
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users