0

I have some data that is a 1:1 map of ids to strings, and I'd love a data structure that lets me query one to get the other. For example:

let mut map:DoubleMap<i32,String> = DoubleMap::new();
map.insert(1,"one");
map.insert(2,"two");
map.get_a(2) // "two";
map.get_b("one") // 1;

I'm sure there's a standard implementation out there, but I'm having a hard time finding the right words for it. Otherwise I can make a simple implementation that just holds two private hashmaps

1
  • 2
    The concept is called a bimap. As an external crate: docs.rs/bimap/latest/bimap (have not tested). Commented May 26 at 22:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.