private void sortAndCollapse(){
  Collections.sort(mSpans);
  mAddsSinceSort=0;
  Iterator iter=mSpans.iterator();
  Span span=null;
  if (iter.hasNext()) {
    span=(Span)iter.next();
  }
  while (iter.hasNext()) {
    Span nextSpan=(Span)iter.next();
    if (span.subsume(nextSpan)) {
      iter.remove();
    }
 else {
      span=nextSpan;
    }
  }
}

private void sortAndCollapse ( ) { Collections . sort ( mSpans ) ; mAddsSinceSort = 0 ; Iterator iter = mSpans . iterator ( ) ; Span span = null ; if ( iter . hasNext ( ) ) { span = ( Span ) iter . next ( ) ; } while ( iter . hasNext ( ) ) { Span nextSpan = ( Span ) iter . next ( ) ; if ( span . subsume ( nextSpan ) ) { iter . remove ( ) ; } else { span = nextSpan ; } } }
sort the spans in ascending order by their start position . after the spans are sorted collapse any spans that intersect into a single span . the result is a sorted , non - overlapping list of spans .
