bidirectional hash table

Started by
2 comments, last by chollida1 17 years, 12 months ago
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
CheersChris
Advertisement
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?
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
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
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
CheersChris

This topic is closed to new replies.

Advertisement