Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-10-07 09:54:52


Lois Goldthwaite wrote:

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

That's exactly what I would do.

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

And I remember having written the skeleton of such a class
in a posting to comp.lang.c++.moderated. A looong time ago.

-- 
Valentin Bonnard

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