title: c++ efficient data structure for bidirectional random access
body: <p>I have elements a and b of two sets A and B. Now these are related to each other (0..1:n cardinality) so each a has at most one partner in B and each b can have several (at least one) associations to items in A.
  A is a set of integer pairs and B are integers.</p>
  
  <p>Is there efficient way to store such a "bi-directional" map? 
  A simple approach would be to use two maps:</p>
  
  <pre><code>map&lt;pair&lt;unsigned int, unsigned int&gt;, unsigned int&gt; AtoB
  map&lt;unsigned int, vector&lt;pair&lt;unsigned int, unsigned int&gt; &gt; &gt; BtoA
  </code></pre>
  
  <p>But perhaps there is good way to deal with this more efficiently.</p>
  
  <p>Thanks for your help</p>