question: 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 ; } } }
target:  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.