MCPcopy
hub / github.com/google/gvisor / InsertWithoutMergingUnchecked

Method InsertWithoutMergingUnchecked

pkg/segment/set.go:439–451  ·  view source on GitHub ↗

InsertWithoutMergingUnchecked inserts the given segment into the given gap and returns an iterator to the inserted segment. All existing iterators (including gap, but not including the returned iterator) are invalidated. Preconditions: - r.Start >= gap.Start(). - r.End <= gap.End().

(gap GapIterator, r Range, val Value)

Source from the content-addressed store, hash-verified

437// - r.Start >= gap.Start().
438// - r.End <= gap.End().
439func (s *Set) InsertWithoutMergingUnchecked(gap GapIterator, r Range, val Value) Iterator {
440 gap = gap.node.rebalanceBeforeInsert(gap)
441 splitMaxGap := trackGaps != 0 && (gap.node.nrSegments == 0 || gap.Range().Length() == gap.node.maxGap.Get())
442 copy(gap.node.keys[gap.index+1:], gap.node.keys[gap.index:gap.node.nrSegments])
443 copy(gap.node.values[gap.index+1:], gap.node.values[gap.index:gap.node.nrSegments])
444 gap.node.keys[gap.index] = r
445 gap.node.values[gap.index] = val
446 gap.node.nrSegments++
447 if splitMaxGap {
448 gap.node.updateMaxGapLeaf()
449 }
450 return Iterator(gap)
451}
452
453// InsertRange inserts the given segment into the set. If the new segment can
454// be merged with adjacent segments, InsertRange will do so. InsertRange

Callers 4

InsertMethod · 0.95
InsertWithoutMergingMethod · 0.95
SplitUncheckedMethod · 0.95
resolveMethod · 0.80

Calls 6

rebalanceBeforeInsertMethod · 0.80
updateMaxGapLeafMethod · 0.80
IteratorStruct · 0.70
GetMethod · 0.65
LengthMethod · 0.45
RangeMethod · 0.45

Tested by

no test coverage detected