Boost logo

Boost Users :

Subject: [Boost-users] [Multi Index Container]: Retrieving a set by ordered non-unique criteria?
From: Steve Hibbert (hiblet_at_[hidden])
Date: 2012-07-04 10:46:50


  I'm a newbie use of Multi Index Containers, apologies if this question is facile.  I have read through the Boost online documentation but am still a bit stumped.   I have a container that contains shared pointers to instants of a custom object type (in this case, financial market orders).   The container has an ordered-non-unique index defined by a member function of the object.  Specifically it is the object's state code, an integer.  At any point in time, I would expect several objects with a state value of 1, several with 2, etc.   I need to pull back the set of objects in a particular state, to a set.  I intend to use the set in testing to 'do something' with one random object in that set, but to all intents and purposes I just need to get the shared pointer to an item in State=1.   How would I pull back the set (or analogous container) of objects that are in State=1?   I am thinking that I first get a reference to the index in question, which is fine.  Would I then do a find(), and would that find() operation return a set-like object?  Or, would I need to do a lower_bound() and upper_bound() operation to find the two enclosing iterators, and then copy all shared-pointers-to-objects to a std::set, and then operate on the set as normal?   Thanks in advance for assistance with this, help is greatly appreciated.   Steve   [I'm aware that if I change state values, I have to do so via the modify function, via the index, been bitten on that point before.]



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