title: Merging Ranges In C++
body: <p>I have a list of randomly ordered unique closed-end ranges R<sub>0</sub>...R<sub>n-1</sub> where</p>
  
  <blockquote>
    <p>R<sub>i</sub> = [r1<sub>i</sub>, r2<sub>i</sub>] (r1<sub>i</sub> &lt;= r2<sub>i</sub>)</p>
  </blockquote>
  
  <p>Subsequently some of the ranges overlap (partially or completely) and hence require merging.</p>
  
  <p>My question is, what are the best-of-breed algorithms or techniques used for merging such ranges. Examples of such algorithms or links to libraries that perform such a merging operation would be great.</p>