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

Pages: 1-

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 6:58

I've come across a problem where I need something like a hash map, but I need to be able to go both ways.

http://en.wikipedia.org/wiki/Bisexual_hash_table

Name: Anonymous 2008-03-10 7:14

>>2
Wikipedia does not have an article with this exact name

Name: Anonymous 2008-03-10 7:35

Not for long...

Name: Anonymous 2008-03-10 8:19

Sure, just create an inverse of the hash function.

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.

Name: Anonymous 2008-03-10 8:50

Hehe, sepples.

Name: Anonymous 2008-03-10 9:11

DON'T HELP HIM!!!

Name: Anonymous 2008-03-10 14:52

http://en.wikipedia.org/wiki/Special:Search/Bisexual_hash_table

You searched for Bisexual hash table [Index]

Results 1-1 of 1

   * Characters of Chrono Trigger
     Relevance: 100.0% - -

what

Name: Anonymous 2008-03-10 14:53

>>9
I have always wondered how the relevance is being calculated.

Name: Anonymous 2008-03-10 15:05

>>9
>>10
article has all three words of your query

Name: Anonymous 2008-03-10 15:19

>>11
That explains only the 100% relevance.

Name: Anonymous 2008-03-10 18:39

>>12
Is that even 100% relevant, or is it just your way of explaining relevance?

Name: Anonymous 2008-03-10 19:10

[citation needed]

Name: Anonymous 2008-03-10 22:24

Dude carries stone.

Name: Anonymous 2008-03-10 23:24

Hash 'em both.

Name: Anonymous 2008-03-10 23:27

Both 'em hash.

Name: Anonymous 2008-03-10 23:34

Ham Smash 'Em Up

Name: Anonymous 2008-03-10 23:39

bash 'em both

Name: Anonymous 2008-03-11 0:13

Shmup

Name: Anonymous 2008-03-11 19:09

SHIELDS UP!

Name: Anonymous 2008-03-11 19:45

>>21
NanoProbe technology

Name: Anonymous 2008-03-12 2:44

>>6
I'm not the OP, but I'm confused why you'd need anything other than a plain vanilla hash table. The requirements stated in the OP are as follows:

* Given a value, the system should be able to retrieve the corresponding key.
* Given a key, the system should be able to retrieve the corresponding value.

When using a regular associative array (implemented with a tree), I can see that you'd need a bi-directional map. With a hash table, however, you shouldn't: the first requirement is met implicitly with the hash function, and the second is synonymous with a hash lookup.

Actually, nevermind. I mis-read the OP, clearly. He wants a hash map, not a hash table.

WHATEVER LOL.

Name: Anonymous 2011-02-04 17:12

<

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