title: Is there an IndexSet and a Range class for Java?
body: <p>In Objective-C Cocoa we have the <code>NSIndexSet</code> class which stores a series of unique indexes efficiently by keeping an array of ranges. E.g. the set 1, 2, ... 30, 57 would be stored as the ranges 1-30 and 57 rather than an array of 32 numbers. This facilitates huge selections to be stored in a simple and fast way. For example, if all rows between 1 and a million in a table selected, the index set collapses to just a tiny range and is fast to compare and intersect with.</p>
  
  <p>Unfortunately this turns out to be rather hard to Google for. Is there an equivalent class for Java?</p>