MergeUnchecked attempts to merge two neighboring segments. If successful, MergeUnchecked returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, MergeUnchecked returns a terminal iterator. Precondition: first is the predecessor of second: first.NextSegment(
(first, second Iterator)
| 704 | // Precondition: first is the predecessor of second: first.NextSegment() == |
| 705 | // second, first == second.PrevSegment(). |
| 706 | func (s *Set) MergeUnchecked(first, second Iterator) Iterator { |
| 707 | if first.End() == second.Start() { |
| 708 | if mval, ok := (Functions{}).Merge(first.Range(), first.Value(), second.Range(), second.Value()); ok { |
| 709 | // N.B. This must be unchecked because until s.Remove(second), first |
| 710 | // overlaps second. |
| 711 | first.SetEndUnchecked(second.End()) |
| 712 | first.SetValue(mval) |
| 713 | // Remove will handle the maxGap update if necessary. |
| 714 | return s.Remove(second).PrevSegment() |
| 715 | } |
| 716 | } |
| 717 | return Iterator{} |
| 718 | } |
| 719 | |
| 720 | // MergePrev attempts to merge the given segment with its predecessor if |
| 721 | // possible, and returns an updated iterator to the extended segment. All |
no test coverage detected