title: Efficient method to find unique values in 2D std::vector<vector<double>>
body: <p>Given a 1D vector <code>std::vector&lt;double&gt; v</code>, the most efficient way to identify unique elements that I know is:</p>
  
  <pre><code>sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  </code></pre>
  
  <p><strong>What is the most efficient way to find the unique elements in 2D vector (i.e. the unique elements among all the elements of 2D matrix)</strong> <code>std::vector&lt;std::vector&lt;double&gt;&gt; v</code> </p>
  
  <p>EDIT: One obvious solution could be to flatten the 2D matrix and apply the above method, but is there any more efficient way?</p>