Sign in to follow this  
chollida1

bidirectional hash table

Recommended Posts

I'm looking for a data structure that is akin to a bidirectional hash table. I've got an SVG DOM structure on one side and my internal rendering structures on the other and I"d like to map between them. I'd like to be able to say given a DOM node, find my internal rendering struct. or given an internal rendering struct get me the corresponding DOM node. If I only wanted to go one way I'd use a hash table, but I need to be able to look up from either direction. Any one have any experince with such a structure?? Cheers Chris

Share this post


Link to post
Share on other sites
Just use two hash tables. One where you has the "DOM node" and one where you hash the "internal rendering struct".
Or could you just store pointers to each other in both?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You might want to take a look at the Boost Multi-index
Containers Library:

http://boost.org/libs/multi_index/doc/index.html

In particular, there's an example of hw to use the
library to obtain a bidirectional map at:

http://boost.org/libs/multi_index/doc/examples.html#example4

The example uses so-called ordered indices, but it
can be trivially modified to take advantage of hashed
indices instead, so providing the kind of data structure
you're after.

HTH,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Share this post


Link to post
Share on other sites
Quote:
Original post by iMalc
Just use two hash tables. One where you has the "DOM node" and one where you hash the "internal rendering struct".
Or could you just store pointers to each other in both?


Thanks iMalc, I thought about that but didnt' want to influence any one by saying that:). I was hopeing for a more elegant solution than having parallel structures that need to be kept in sync:)

Anonymous poster, you nailed it! Thanks very much!

Cheers
Chris

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this