andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
282 stars 28 forks source link

Bidirectional dictionary #104

Open serenity4 opened 2 years ago

serenity4 commented 2 years ago

I have a use case which requires a bidirectional mapping (similar to Bijections), and wondered what would be preferred between either contributing such an implementation to Dictionaries or creating a new package. I personally don't have any particular opinion on that, hence me asking.

What I essentially seek to reuse is this source file with these tests. Do you think such functionality would belong here or in a separate package?

andyferris commented 2 years ago

That's a good question - I think either might be possible. If you just want something simple like you have done (with Dictionary inside) you could just make a small package.

I think here we could support a generic operation for "inverting" a mapping and have a wrapper type behaving like BijectiveMapping but supporting AbstractDictionary inside. An example of a dictionary type that's already bidirectional are the tokens dictionaries (keys are one-to-one with tokens) so it would be cool to be able to "invert" that sometimes.