Home » U++ Library support » U++ Core » what about VectorBiMap / ArrayBiMap ?
Re: what about VectorBiMap / ArrayBiMap ? [message #26430 is a reply to message #26429] |
Fri, 30 April 2010 22:54   |
 |
mirek
Messages: 14267 Registered: November 2005
|
Ultimate Member |
|
|
kohait00 wrote on Fri, 30 April 2010 10:32 | @Mirek:
direction is meant to be key -> value, or value -> key;
say i have a pair of Strings, in a capabale VectorBiMap,
and add "MyKey" | "MyValue" pair (here spoken as key/value), then i will be able to find location of "MyValue" *VIA HASH* of "MyKey", what is trivial and possible with VectorMap.
but what if i want to be able to find location of "MyKey" (which is same location of "MyValue") *VIA HASH* of "MyValue"?
this is currently not possible, except manually using 2 Indexes, separately driving their api together. But is quite cool.
usecase: (simple and stupid) a dictionary 2 languages with exactly a pair of words like "Buenos Dias" <=> "Hi" (stupid)
and a *HIGH* speed translation in *BOTH* directions needed.
|
Index<String> spain;
Index<String> english;
void AddWord(const String& sp, const String& en)
{
spain.Add(sp);
english.Add(en);
}
String EnglishToSpain(const String& w)
{
int q = english.Find(w);
return q >= 0 ? spain[q] : String();
}
String SpainToEnglish(const String& w)
{
int q = spain.Find(w);
return q >= 0 ? english[q] : String();
}
Mirek
|
|
|
Goto Forum:
Current Time: Fri Aug 29 17:53:14 CEST 2025
Total time taken to generate the page: 0.04408 seconds
|