Boost logo

Boost :

From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-06-10 10:16:54


Hello Matias,

Sunday, June 10, 2007, 3:33:03 PM, you wrote:

> On 6/10/07, Andrey Semashev <andysem_at_[hidden]> wrote:
>> Hello Matias,
>>
>> > You can use ordered_index if your application can work with O(log(n)) lookup.
>>
>> I don't see how could I do that since for ordering the elements in the
>> container I need strict weak ordering, and for element lookup by a
>> full string I need a more relaxed ordering. For example:
>>
>> ax
>> a?
>> a*

> It was a long shot, I was more interested in you trying out bimap :)
> Anyway as you have put it, it seem that the lexicographical approach
> is not bothering you to much, you may want to try orered_non_unique
> that allows you to insert multiple keys.

That allows the same wildcards to coexist in the container which is
not what I need either.

>> 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 > >

What is the value_type of the container then? What are the names of
the two keys and info in it? 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. Obscure names of value_type members an dependency on
bimap are very undesirable.

-- 
Best regards,
 Andrey                            mailto:andysem_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk