text: public WeightedPhraseInfo( Collection< WeightedPhraseInfo > toMerge ) {Iterator< WeightedPhraseInfo > toMergeItr = toMerge.iterator();if ( !toMergeItr.hasNext() ) {throw new IllegalArgumentException( "toMerge must contain at least one WeightedPhraseInfo." );}WeightedPhraseInfo first = toMergeItr.next();@SuppressWarnings( { "rawtypes", "unchecked" } )Iterator< Toffs >[] allToffs = new Iterator[ toMerge.size() ];termsInfos = new ArrayList<>();seqnum = first.seqnum;boost = first.boost;allToffs[ 0 ] = first.termsOffsets.iterator();int index = 1;while ( toMergeItr.hasNext() ) {WeightedPhraseInfo info = toMergeItr.next();boost += info.boost;termsInfos.addAll( info.termsInfos );allToffs[ index++ ] = info.termsOffsets.iterator();}MergedIterator< Toffs > itr = new MergedIterator<>( false, allToffs );termsOffsets = new ArrayList<>();if ( !itr.hasNext() ) {return;}Toffs work = itr.next();while ( itr.hasNext() ) {Toffs current = itr.next();if ( current.startOffset <= work.endOffset ) {work.endOffset = Math.max( work.endOffset, current.endOffset );} else {termsOffsets.add( work );work = current;}}termsOffsets.add( work );}