title: Algorithm for getting the empty parts of a range
body: <p>I have a range from say 1013 to 20798654. I have a queue of ranges that I am working my way through. What I want is a collection of ranges that make up the space that the ranges from the queue don't cover. So for example above if I had just two new ranges coming in [1017, 1100] and [1000000,1500000] then I would want a set of ranges like [[1013,1017],[1100,1000000],[1500000,20798654]].</p>
  
  <p>Does anyone know of an efficient way of doing this? The main range is in the region of 6Bn wide and we have around 170m ranges in the queue.</p>