title: Efficient way to remove items from vector
body: <p>Currently, I plan to remove all items from vector, which is not found in a set.</p>
  
  <p>For example :</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;set&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      std::set&lt;string&gt; erase_if_not_found;
      erase_if_not_found.insert("a");
      erase_if_not_found.insert("b");
      erase_if_not_found.insert("c");
  
      std::vector&lt;string&gt; orders;
      orders.push_back("a");
      orders.push_back("A");
      orders.push_back("A");
      orders.push_back("b");
      orders.push_back("c");
      orders.push_back("D");
  
      // Expect all "A" and "D" to be removed.
      for (std::vector&lt;std::string&gt;::iterator itr = orders.begin(); itr != orders.end();) {
          if (erase_if_not_found.find(*itr) == erase_if_not_found.end()) {
              orders.erase(itr);
              // Begin from start point again? Do we have a better way?
              itr = orders.begin();
          } else {
              ++itr;
          }
      }
  
      for (std::vector&lt;std::string&gt;::iterator itr = orders.begin(); itr != orders.end(); ++itr) {
          std::cout &lt;&lt; *itr &lt;&lt; std::endl;
      }
  
      getchar();
  }
  </code></pre>
  
  <p>Although the above code work, it is not efficient, as I begin from vector's start point each time I delete an item.</p>
  
  <p>Is there a better way?</p>