2-Way StringToString Map
-
I want to "connect" two strings together. Like MFC's CMapStringToString, just both ways, and I'm not using MFC. There should be no limit to how many strings that can be stored. Btw, I've made my own little string-class, so only need a method for mapping them together. I also want the method to be fast, so iteration through a huge list of strings is not something I want to do. Anyone got an elegant solution...? :confused: Sprudling ;)
-
I want to "connect" two strings together. Like MFC's CMapStringToString, just both ways, and I'm not using MFC. There should be no limit to how many strings that can be stored. Btw, I've made my own little string-class, so only need a method for mapping them together. I also want the method to be fast, so iteration through a huge list of strings is not something I want to do. Anyone got an elegant solution...? :confused: Sprudling ;)
Use a single list or array to store all the strings. Be sure each entry is unique. Then use one map to map the indices/pointers to each other in whatever combinations are appropriate. This should be pretty fast, since the strings are only stored once, and string comparisons need only be made when new strings are added to the list. And if words were wisdom, I'd be talking even more.
The Offspring, I Choose
-
I want to "connect" two strings together. Like MFC's CMapStringToString, just both ways, and I'm not using MFC. There should be no limit to how many strings that can be stored. Btw, I've made my own little string-class, so only need a method for mapping them together. I also want the method to be fast, so iteration through a huge list of strings is not something I want to do. Anyone got an elegant solution...? :confused: Sprudling ;)
You could also look at the STL's pair<>.
-
Use a single list or array to store all the strings. Be sure each entry is unique. Then use one map to map the indices/pointers to each other in whatever combinations are appropriate. This should be pretty fast, since the strings are only stored once, and string comparisons need only be made when new strings are added to the list. And if words were wisdom, I'd be talking even more.
The Offspring, I Choose
It would not be fast at all if it was a list. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
-
I want to "connect" two strings together. Like MFC's CMapStringToString, just both ways, and I'm not using MFC. There should be no limit to how many strings that can be stored. Btw, I've made my own little string-class, so only need a method for mapping them together. I also want the method to be fast, so iteration through a huge list of strings is not something I want to do. Anyone got an elegant solution...? :confused: Sprudling ;)
You'll need a containter for strings and two maps - one for each 'way'. STL classes will be OK for that. Aggregate these objects into one class, provide an interface - that's all. Tomasz Sowinski -- http://www.shooltz.com
-
It would not be fast at all if it was a list. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
-
Because you'd have indices into a container to look up the actual strings, and list lookups require walking the list, they are slow compared to arrays which have instant lookup. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
-
Because you'd have indices into a container to look up the actual strings, and list lookups require walking the list, they are slow compared to arrays which have instant lookup. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002