title: How to improve a structure storing many results?
body: <p>I have a <code>Polygon</code> structure and a function with the following signature</p>
  
  <pre><code>Polygon myfunction(Polygon &amp;pol1, Polygon &amp;pol2, int rot1, int rot2); 
  </code></pre>
  
  <p>in which pol1 and pol2 are <code>Polygon</code>s, rot1 and rot2 are rotation applied to pol1 and pol2.</p>
  
  <p>I need to store all the results of <code>myfunction</code> applied to a set of polygons and a set of admissible rotations. </p>
  
  <p>So, for example, if I have 100 polygons and 4 admissible rotations, I need to store 100*100*4*4 = 160000 polygons. I'm aware that I need a lot of memory, but I'm ok with it.</p>
  
  <p>For the moment I'm storing them in a container like that:</p>
  
  <pre><code>vector&lt;vector&lt;vector&lt;vector&lt;Polygon&gt;&gt; results;
  </code></pre>
  
  <p>so that calling <code>results[pol1][pol2][rot1][rot2];</code> I get the right polygon.</p>
  
  <p>I know that accessing a single result could be quite inefficient, so how can I improve it? </p>