Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What data structure to use?

Name: Anonymous 2008-03-10 6:52

Sup /prog/
I've come across a problem where I need something like a hash map, but I need to be able to go both ways. That is, I should be able to retrieve a value based on a key, obviously, but I should also be able to get to the key given a value. The key set and value set contain unique values. I require logarithmic lookup time in both cases.

Is there a way to do this, without using two hashtables? I'm using sepples btw



Name: Anonymous 2008-03-10 8:25

http://en.wikipedia.org/w/index.php?title=Talk:Bisexual_hash_table&action=history

Someone redirected it to “Bidirectional map,” then wiped it again a minute later. Second thoughts much?

Anyway, a bidirectional map is what you want. It's essentially a pair of hash tables. It's in Boost (called Bimap), so just use that. Hehe, bi.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List