/* If we have added any spans since we last *sortedandcollapsedourlistofspans *thenweneedtoresortandcollapse.
*/ if (mAddsSinceSort > 0) {
sortAndCollapse();
}
/* The SpanIntersection comparator considers *twospansequaliftheyintersect.If *thesearchfindsamatchthenwehavean *intersection.
*/ int found = Collections.binarySearch(mSpans, new Span(start, end),
SpanIntersection.instance);
doesIntersect = found >= 0;
/* The addInfinite() method has been invoked so *everythingintersectthisinstance.
*/
} else {
doesIntersect = true;
}
/* Have 'span' start at the first span in *thecollection.Thecollectionmaybeempty *sowe'recareful.
*/
Span span = null; if (iter.hasNext()) {
span = iter.next();
}
/* Loop over the spans collapsing those that intersect *intoasinglespan.
*/ while (iter.hasNext()) {
Span nextSpan = iter.next();
/* The spans are in ascending start position *orderandsothenextspan'sstartingpoint *iseitherinthespanwearetryingtogrow *oritisbeyondthefirstspanandthusthe *twospansdonotintersect. * *span:<----------< *nextSpan:<------(intersects) *nextSpan:<------(doesn'tintersect) * *Ifthespansintersectthenwe'llremove *nextSpanfromthelist.IfnextSpan's *endingwasbeyondthefirst'sthen *weextendthefirst. * *span:<----------< *nextSpan:<-----<(don'tchangespan) *nextSpan:<-----------<(growspan)
*/
if (span.subsume(nextSpan)) {
iter.remove();
/* The next span did not intersect the current *spanandsoitcannotbecollapsed.Instead *itbecomesthestartofthenextsetofspans *tobecollapsed.
*/
} else {
span = nextSpan;
}
}
}
/* We can only subsume 'otherSpan' if *itsstartingpositionliesinour *interval.
*/ boolean isSubsumed = contains(otherSpan.mStart);
/* If the other span's starting position *wasinourintervalandtheotherspan *waslongerthanthisspan,thenweneed *togrowthisspantocoverthedifference.
*/ if (isSubsumed && otherSpan.mEnd > mEnd) {
mEnd = otherSpan.mEnd;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.