Hello Curtis, On Fri, Nov 27, 2009 at 1:41 PM, Curtis Himel <chimel@indra-systems.com> wrote:
I have a question with sorting of sets in the bimap framework. I have a bimap declared thus:
//Boost Bimap requires this predicate struct setup struct AreDecalIDsInCorrectRenderOrderStruct { bool operator() (const short nDecalID1, const short nDecalID2) const { //Do comparison } };
typedef boost::bimap<boost::bimaps::unordered_multiset_of<int>, boost::bimaps::set_of<short, AreDecalIDsInCorrectRenderOrderStruct>> intMultisetShortSetBimap;
intMultisetShortSetBimap m_mStructureIDToLinkedDecalID;
Til this point, everything is ok and you have customized the right set of the bimap with your custom sorting predicate.
The problem is this isn't working as I expected. I'm expecting that when I insert elements using:
m_mStructureIDToLinkedDecalID.insert(intMultisetShortSetBimap ::value_type(nStructureID, nDecalID)); and then later retrieve them using:
pair<intMultisetShortSetBimap ::left_const_iterator, intMultisetShortSetBimap ::left_const_iterator> equalRange = m_mStructureIDToLinkedDecalID.left.equal_range(nStructureID);
that the retrieved elements with equal range would be sorted according to the predicate I used. But they aren't. Instead their order is dependent on the order they were inserted.
The thing is that you are using the left view of the bimap, and not the one you have customized. Try using the right view map, it should work as you expect. Best regards Matias