Re: [Boost-users] [boost bimap]- question on use of optionalsorting predicate for set_of declarations

"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." I didn't understand why switching views would work, and it didn't do what I wanted. (I tried it anyway.) If I use the right view, then I'm looking up the multiset ints with a unique short, right? I want to go the other way- I want to look up a sorted range of unique shorts from the right side with a non-unique int from the left side. I might have misunderstood you, but I don't see how using the right view works there. Thanks, 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.

"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."
On Sat, Nov 28, 2009 at 2:37 AM, Curtis Himel
I didn't understand why switching views would work, and it didn't do what I wanted. (I tried it anyway.) If I use the right view, then I'm looking up the multiset ints with a unique short, right? I want to go the other way- I want to look up a sorted range of unique shorts from the right side with a non-unique int from the left side. I might have misunderstood you, but I don't see how using the right view works there.
Ok, I think I have understood you. If your data looks like: int(1000) --- short(6) int(1000) --- short(7) int(1000) --- short(8) int(2000) --- short(1) int(2000) --- short(2) int(2000) --- short(3) int(3000) --- short(14) int(3000) --- short(16) You want to be able to get 1,2,3 in that order when looking with 2000. Is that right? Both sets of the bimaps (the ints, and the shorts in your case) works separately, exactly as with standard map, your comparison function can not take into account the values of the other set. Imagine trying to achieve what you want with: std::unordered_map< int, short, ... > So it is not possible to get the data as you want using the left or the right views that mimics the standard map behaviour. However Boost.Bimap gives you one more view that takes both sides into account. Please read about it here: http://tinyurl.com/boost-bimap-coll-of-relations You will need something like: boost::bimap< int, short, set_of_relations< compare_two_relations > > The compare_two_relations will compare the ints and if they are equal, the shorts ( ra.left < rb.left or ( ra.left == rb.left && ra.right < rb.right ) ) If this abstraction does not work for you, because for example you do not the left and right views to mimic the standard maps you may have to reconsider using Boost.MultiIndex instead. Best regards Matias
participants (2)
-
Curtis Himel
-
Matias Capeletto