title: Seek item within vector
body: <p>I have a vector of real values, sorted by increasing order.</p>
  
  <p>These values can be within the range <code>[0, 1]</code>. Then I pick a value <code>x</code> within this range and I need to find which is the index of the smaller value greater or equal to <code>x</code>.</p>
  
  <p>I can solve this problem by iterating over the whole array:</p>
  
  <pre><code>vector&lt;double&gt; values;
  double x;
  
  for (auto val : values)
  {
      if (x &lt;= values)
      {
          // found
          break;
      }
  }
  </code></pre>
  
  <p>Is there a faster way to get the same result? I was thinking about a binary search, but how to implement it?</p>