Boost logo

Boost :

From: Lois Goldthwaite (loisg_at_[hidden])
Date: 1999-10-06 07:25:28


Couldn't you accomplish this with a second map?

typedef map<key_type, value_type> regular_map;
typedef map<value_type, regular_map::iterator> reverse_map;

Map iterators remain valid unless you delete the node they're pointing to.
To maintain consistency between the two maps as you insert and delete
values, you might want to wrap them up in a class together, with
pass-through functions in its interface.

I guess this is what you are asking about, but it doesn't seem too difficult
to write, on the face of it.

Lois

niko_pro_at_[hidden] wrote:

> Do we have a template based two map/multimap class which is indexed on
> key and value both. My requirement is to have the key for a given value
> (as opposed to getting the value from a key). As for now, i've to
> itarate the entire map/multimap (which may have several thousand
> entries), but this is very inefficent.
>
> ------------------------------------------------------------------------
> Join theglobe.com the premiere online community! Take advantage of
> FREE homepages, Stock quotes, News, Chat, Games and more! Interact
> with people just like you! http://clickhere.egroups.com/click/1042
>
> eGroups.com home: http://www.egroups.com/group/boost
> http://www.egroups.com - Simplifying group communications


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