Boost logo

Boost Users :

Subject: [Boost-users] [boost bimap]- question on use of optional sorting predicate for set_of declarations
From: Curtis Himel (chimel_at_[hidden])
Date: 2009-11-27 13:41:53


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;

 
 
 
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. I've verified that my predicate is being called on insertions.
Am I misunderstanding the purpose of passing a sorting predicate to a set_of declaration? If so, what does the sorting actually do and is there a way to get boost::bimap to do what I want?
Thanks for any help.
 
-Curtis
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

This e-mail and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
If you have received this e-mail in error please notify the
originator of the message. This footer also confirms that this
e-mail message has been scanned for the presence of computer viruses.

Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Indra Systems, Inc.



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