code: func (m *merger) next() (index, offs int, start bool) {
  	// find the next smallest offset where a segment starts or ends
  	offs = infinity
  	index = -1
  	for i, seg := range m.segments {
  		switch {
  		case seg[0] < offs:
  			offs = seg[0]
  			index = i
  			start = true
  		case seg[1] < offs:
  			offs = seg[1]
  			index = i
  			start = false
  		}
  	}
  	if index < 0 {
  		// no offset found => all selections merged
  		return
  	}
  	// offset found - it's either the start or end offset but
  	// either way it is ok to consume the start offset: set it
  	// to infinity so it won't be considered in the following
  	// next call
  	m.segments[index][0] = infinity
  	if start {
  		return
  	}
  	// end offset found - consume it
  	m.segments[index][1] = infinity
  	// advance to the next segment for that selection
  	seg := m.selections[index]()
  	if seg == nil {
  		return
  	}
  	m.segments[index] = seg
  	return
  }
docs: // next returns the next segment change: index specifies the Selection
  // to which the segment belongs, offs is the segment start or end offset
  // as determined by the start value. If there are no more segment changes,
  // next returns an index value < 0.
  //