Let T_1 and T_2 be two types and f: Dom(T_1) -> Dom(T_2) be an injective function which is not a bijection; and for the sake of discussion suppose I get a representation of f as disparate pairs rather than code for computing it. Now, I need to be able to apply both f and f^{-1} relatively quickly, so I was thinking of a map in each direction. Then it occurred to me that I might want a data structure for these two maps together - as I have multiple such f's.
I naturally thought "Hmm, I'm sure Boost must have something like that", and indeed, Boost has a Bimap structure. The thing is, that one is intended for general binary relations; also, it has to account for the possibility of repeated insertions without re-optimizing the structure each time, while in my case I only insert once, then do many lookups. So, I feel that's bimap might be a bit overkill for me, and unoptimized for my use case. Is that true?
Notes:
- I'm interested in time complexity (and actual time) at the expense of space.
- Same question for non-injective f (with f^{-1} being a non-function relation).