Boost logo

Boost :

From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2007-06-10 07:33:03


On 6/10/07, Andrey Semashev <andysem_at_[hidden]> wrote:
> Hello Matias,
>
> Sunday, June 10, 2007, 1:04:47 AM, you wrote:
>
> >> I failed to make use of B.MI ordered or hashed indices because of the
> >> constraints they apply to the CompatibleKey, CompatibleCompare,
> >> CompatibleHash and CompatiblePred objects I would have to provide.
>
> > If given two strings s1 and s2 with or without wildcards you can define
> > an order between them, something like:
>
> > ?
> > *
> > ??
> > ?*
> > ..
> > ..
> > a
> > a?
> > a*
> > ..
> > ..
>
> > 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.

> > With respect to the structure layout you are using, a bimap can be used:
>
> > bimap< set_of<string, WildcardOrder>, unordered_set_of<int> >
>
> 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";

Best regards
Matias


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