Does Racket have a bi-directional hash file?
That is, a hash card that can in constant time, receives a key and searches for a value, or sets a value and searches for a key? I would be happy for an API that looks something like this:
(define my-map (bidirectional-hash '(key1 val1) '(key2 val2)))
(bidirectional-hash-ref my-map 'key 'key1) ; => val1
(bidirectional-hash-ref my-map 'val 'val2) ; => key2
If the characters keyand valtell the hash map that it is given val, looking for the key, or the given key, and looking for val. In both cases, I want this to be done in constant O (1) time.
I know that you can do this using two hash tables that are inverted from each other, but I need a structure built into Racket (or an existing library).
source
share