title: distance between std::set begin() and std::set iterator in O(logn)
body: <p>I need to find the index of an element in std::set. This index can be visualized as the distance of the iterator from the beginning.
  One way can be:</p>
  
  <pre><code>for(int i = 0, set&lt;int&gt;::iterator it = s.begin(); it != iteratorToBeFound; ++it, ++i);
  </code></pre>
  
  <p>This clearly takes O(n) time. But we know that the distance from the root in a binary search tree as implemented by set internally can be found in O(log n) time.</p>
  
  <p>Is their any way to implement the same to find the index in O(log n) time in C++ set?</p>