Bidirectional CMap
-
I need a map where I can find the value to a key and also a key to a value. Since I can't find any article on Codeproject regarding this issue, I ask this question here: Is there a simple solution to this? My idea was to simply use two CMaps: CMap<KEY, KEY&, VALUE, VALUE&> and CMap<VALUE, VALUE&, KEY, KEY&>. Is there a simpler approach? Thanks for any help. Konrad
-
I need a map where I can find the value to a key and also a key to a value. Since I can't find any article on Codeproject regarding this issue, I ask this question here: Is there a simple solution to this? My idea was to simply use two CMaps: CMap<KEY, KEY&, VALUE, VALUE&> and CMap<VALUE, VALUE&, KEY, KEY&>. Is there a simpler approach? Thanks for any help. Konrad
This came up recently somewhere. I think someone may have posted a version at Boost. http://www.boost.org[^]. In the past I've just done as you've done. Ah, just done a search. See here http://www.boost.org/libs/multi_index/doc/examples.html#example4[^] Kevin
-
This came up recently somewhere. I think someone may have posted a version at Boost. http://www.boost.org[^]. In the past I've just done as you've done. Ah, just done a search. See here http://www.boost.org/libs/multi_index/doc/examples.html#example4[^] Kevin
Isn't there a simple MFC class somewhere out there as extension to CMap, because I don't want to use the huge boost library? Konrad
-
Isn't there a simple MFC class somewhere out there as extension to CMap, because I don't want to use the huge boost library? Konrad
I've not come across one and yes I too am put of by the huge Boost library.:(( I vaguely recall coming across a simpler solution somewhere but I can't think where. Maybe on CodeGuru? Kevin
-
Isn't there a simple MFC class somewhere out there as extension to CMap, because I don't want to use the huge boost library? Konrad
Konrad Windszus wrote: because I don't want to use the huge boost library? You probably can insert only the relevant classes into your project. Boost is all source code. I am doing so with the smart-pointer classes from boost. You will want to stay well clear of the MFC-containers, as the STL containers are better in all respects, and are well documented and portable.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
-
I need a map where I can find the value to a key and also a key to a value. Since I can't find any article on Codeproject regarding this issue, I ask this question here: Is there a simple solution to this? My idea was to simply use two CMaps: CMap<KEY, KEY&, VALUE, VALUE&> and CMap<VALUE, VALUE&, KEY, KEY&>. Is there a simpler approach? Thanks for any help. Konrad
If you don't expect the number of keys to be very large, you could just write a simple function to do the latter (i.e. return the collection of keys that map to the value). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
I need a map where I can find the value to a key and also a key to a value. Since I can't find any article on Codeproject regarding this issue, I ask this question here: Is there a simple solution to this? My idea was to simply use two CMaps: CMap<KEY, KEY&, VALUE, VALUE&> and CMap<VALUE, VALUE&, KEY, KEY&>. Is there a simpler approach? Thanks for any help. Konrad
-
Thank you very much. I also found that article, after I posted my request. I already programmed my own CMap extension class, because I use MFC in my project (and therefore don't use STL, because I don't want to mix them). I will write an article about my extension class for codeproject when I have some free time. Regards Konrad
-
I've not come across one and yes I too am put of by the huge Boost library.:(( I vaguely recall coming across a simpler solution somewhere but I can't think where. Maybe on CodeGuru? Kevin
Nearly all of Boost is in headers and it does not add lots of code to your app. The fact that it is large is irrelevant IMO. MFC and STL are also large. I would definitely recommend using STL and Boost wherever possible instead of the MFC Containers (which I used to use heavilly). Boost.MultiIndex will do what you want and it looks quite elegant. Of course you can use two CMap's or two STL map's but why would you want to. Make the move to STL and Boost and you'll never regret it.;) Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
Nearly all of Boost is in headers and it does not add lots of code to your app. The fact that it is large is irrelevant IMO. MFC and STL are also large. I would definitely recommend using STL and Boost wherever possible instead of the MFC Containers (which I used to use heavilly). Boost.MultiIndex will do what you want and it looks quite elegant. Of course you can use two CMap's or two STL map's but why would you want to. Make the move to STL and Boost and you'll never regret it.;) Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
Neville Franks wrote: The fact that it is large is irrelevant IMO. Well, I've only comparatively recently moved from dial-up to broadband. With dial-up it just wasn't worth it. Now I've got broadband it's more psychological. Neville Franks wrote: I would definitely recommend using STL and Boost wherever possible instead of the MFC Containers (which I used to use heavilly). Recently I've been more focused on .NET,so I've not had much incentive to look into Boost. When I do get to do C++ it's invariably maintenance work on code that's barely heard of STL, yet alone Boost! (For that nmatter it's often barely heard of MFC's data structures!) I just don't think it would go down too well if I downloaded Boost just to do maintenance work. However, for new work or new extensions to MFC apps. I tend to go for STL containers nowadays. Still, I do intend to give Boost a try at some point. Kevin
-
Konrad Windszus wrote: because I don't want to use the huge boost library? You probably can insert only the relevant classes into your project. Boost is all source code. I am doing so with the smart-pointer classes from boost. You will want to stay well clear of the MFC-containers, as the STL containers are better in all respects, and are well documented and portable.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
jhwurmbach wrote: You will want to stay well clear of the MFC-containers, as the STL containers are better in all respects, and are well documented and portable. If you're working on an MFC app. it's generally going to be non-portable anyway, so why is it important to use portable STL? I agree that the STL containers are better and I use them for that reason, not because they're portable. Kevin
-
Thank you very much. I also found that article, after I posted my request. I already programmed my own CMap extension class, because I use MFC in my project (and therefore don't use STL, because I don't want to mix them). I will write an article about my extension class for codeproject when I have some free time. Regards Konrad
Konrad Windszus wrote: because I use MFC in my project (and therefore don't use STL, because I don't want to mix them). Why not? What's the problem? Kevin