
On 6/10/07, Andrey Semashev <andysem@mail.ru> wrote: Hi andrey
No, bimap doesn't seem to suit me since the container holds not only the wildcard and int.
You can use it anyway :) The last version of the lib includes a new feature called: relations information. If you do not need indexes over that information you can include it in bimap:
bimap< set_of<string, WildcardOrder>, unordered_set_of<int>, with_info< string > >
And then:
bm.left.find("ab*c")->info = "info"; // or... bm.left.info_at("ab*c") = "info"; bm.right.find(3)->>info = "info"; // or... bm.right.info_at(3) = "info";
I guess, if I need to put more than one value as info, I have to make a struct of them?
struct MyInfo { string Data1; int Data2; bool Data3; };
bimap< set_of<string, WildcardOrder>, unordered_set_of<int>, with_info< MyInfo > >
Exactly.
What is the value_type of the container then?
Why is that important to you? Even when you do not use additional information the value type of the container is an implementation detail. But that's is why value_type exists. You do no have to worry about the implementation type.
What are the names of the two keys and info in it?
In this bimap: bm::left_map::value_type (signature-compatible to std::pair<left_type,right_type>) ---------------------------------- first : is the left element that acts as the key second : is the right element that acts as the data info : is the information, that do not participate in the map bm::right_map::value_type (signature-compatible to std::pair<right_type,left_type>) ---------------------------------- first : is the right element that acts as the key second : is the left element that acts as the data info : is the information, that do not participate in the map bm::value_type ---------------------------------- first : is the right element second : is the left element info : is the information, that do not participate in the map
As I'm not hoping it is more or less relevant to their real semantic, I don't think it's the best choice for me, because this value_type is exposed to other components of the application.
I do not see a problem here.
Obscure names of value_type members,
They are not obscure.
an dependency on bimap are very undesirable.
Ok that is your call :) If you want to give your users better names you can use tags: struct wildcard_string {}; struct id {}; struct fancy_info_name {}; typedef bimap< set_of< tagged<string, wildcard_string>, WildcardOrder>, unordered_set_of< tagged< int, id > >, with_info< tagged< MyInfo, fancy_info_name > > bm_type; bm_type bm; ... cout << bm.by<id>.find(2)->get<wilcard_string>() I am not saying that a bimap is better than a multi_index_container here. I just want to point out that you "can" use it if you want. Best Regards Matias Bimap online docs: http://tinyurl.com/22sja5