title: c++ Best Way to access properties of a vector element
body: <p>So this is a question more so for my own knowledge.
  Is there any kind of best practice for accessing multiple properties of a single element in a vector? Sorry if that question doesn't make much sense. Let me give a scenario:</p>
  
  <p>I was working on some code and got to a point where I created a vector of a struct. To make sure we aren't duplicating the data in the vector, we check multiple pieces of the incoming data against already existing data in the vector via a for loop. The data is being added from multiple, independent sources, sometimes at rapid succession, so it's a bit difficult to do a master ID for each entry before this point. The code ends up looking something like this:</p>
  
  <pre><code>    vector&lt;testStruct&gt; test;
      void addDataToVector(int _iData1, string _sData2, unsigned int _uiData3){
         testStruct tmp;
         tmp.iData1 = _iData1;
         tmp.sData2 = _sData2;
         tmp.uiData3 = _uiData3;
  
         if(test.size() &gt; 0){
              for(size_t i = 0;; i &lt; test.size(); i++){
                   if(test[i].iData1 == tmp.iData1 &amp;&amp;
                        test[i].sData2 == tmp.sData2 &amp;&amp;
                        test[i].uiData3 == tmp.uiData3){
                        break;
                   }else{
                        test.push_back(tmp);
                   }
               }
          }else{
               test.push_back(tmp);
          }
      }
  </code></pre>
  
  <p>In some other programming languages, I have learned that doing multiple calls on the same element of an array like this is a bit wasteful. In Action Script 3, I have learned that it is better to assign the element's content to a temporary variable then use that variable for the multiple calls instead of constantly accessing the vector over and over.
  I am wondering if there is any such thing to be wary of in c++? I understand that a vector is a pointer... I think. But I'm not sure if that alleviates a lot of this or if I need to still be on the look out for such a thing. I have tried looking around for similar data/answers but wasn't exactly sure how to word my search.</p>
  
  <p>Any help or pointers (hehe get it?) would be appreciated.</p>