title: Improving performance using QHash and QList
body: <p>I'm using these classes:</p>
  
  <p><code>QHash</code>: rapresenting all the objects of the scene (cannot modify this class)</p>
  
  <p><code>QList</code>: rapresenting all the objects selected. It contains IDs (saved as <code>int</code>) </p>
  
  <pre><code>//DrawSelectedObjects(){
  
  QHash&lt;QString, SceneObject*&gt;&amp; hash=sc-&gt;getObj();
  QList&lt;int&gt; tempList = HitsList;
  
  int counter =0;
  
  for (QHash&lt;QString,SceneObject*&gt;::ConstIterator i = hash.begin();i!=hash.end();++i) {
  
       if (tempList.startsWith(counter)) {
              .
              Draw_as_selected()
              .
              tempList.removeOne(counter);
       }
  }
  }
  </code></pre>
  
  <p>So,for example if I select the object #77,its ID is saved in <code>Hitslist</code> (<code>QList</code>).</p>
  
  <p>After that <code>HitsList</code> is sorted and <code>DrawSelectedObjects()</code> is called.</p>
  
  <p>It has to iterate the <code>QHash</code> until <code>counter=77</code> and <code>Draw_as_selected()</code>. After that,The first element of the <code>QList</code> is removed, pulling to the front the second one.</p>
  
  <p>This function is called EVERY time one object is selected. With small imported scenes its all ok,but when I'm using files >10MB I can see some output lag (its obvious, because I am iterating through a huge <code>QHash</code>).</p>
  
  <p>Could you suggest me a more efficient way to do this? Any help would be appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>Thank you for your reply.The problem is that I can't get rid of that <code>QList&lt;int&gt;</code> (iI can push only integers on top of OpenGL selection stack).</p>
  
  <p>So another way from the above solution is to do <code>QString.toInt()</code> for every element of the <code>QHash</code> and save them into the <code>QList&lt;int&gt;</code>.</p>
  
  <p>The fact is...how find out the correct <code>QString</code> on the hash using the <code>int</code> (calculated now by conversion from <code>QString</code>, no more from counter) on the <code>QList</code>?</p>