MCPcopy Index your code
hub / github.com/google/gvisor / InsertWithoutMergingRange

Method InsertWithoutMergingRange

pkg/segment/set.go:490–502  ·  view source on GitHub ↗

InsertWithoutMergingRange inserts the given segment into the set and returns an iterator to the inserted segment. All existing iterators (excluding the returned iterator) are invalidated. If the new segment would overlap an existing segment, or if r is invalid, InsertWithoutMergingRange panics. In

(r Range, val Value)

Source from the content-addressed store, hash-verified

488// needs to do additional work between finding the gap and insertion, use
489// InsertWithoutMerging instead.
490func (s *Set) InsertWithoutMergingRange(r Range, val Value) Iterator {
491 if r.Length() <= 0 {
492 panic(fmt.Sprintf("invalid segment range %v", r))
493 }
494 seg, gap := s.Find(r.Start)
495 if seg.Ok() {
496 panic(fmt.Sprintf("new segment %v overlaps existing segment %v", r, seg.Range()))
497 }
498 if gap.End() < r.End {
499 panic(fmt.Sprintf("new segment %v overlaps existing segment %v", r, gap.NextSegment().Range()))
500 }
501 return s.InsertWithoutMerging(gap, r, val)
502}
503
504// TryInsertRange attempts to insert the given segment into the set. If the new
505// segment can be merged with adjacent segments, TryInsertRange will do so.

Callers 15

TestAddRandomFunction · 0.95
TestRemoveRandomFunction · 0.95
benchmarkAddSequentialFunction · 0.95
benchmarkAddRandomFunction · 0.95
benchmarkFindSequentialFunction · 0.95
benchmarkFindRandomFunction · 0.95
benchmarkIterationFunction · 0.95
TestMaxGapAddRandomFunction · 0.80

Calls 7

FindMethod · 0.95
InsertWithoutMergingMethod · 0.95
LengthMethod · 0.45
OkMethod · 0.45
RangeMethod · 0.45
EndMethod · 0.45
NextSegmentMethod · 0.45

Tested by 15

TestAddRandomFunction · 0.76
TestRemoveRandomFunction · 0.76
benchmarkAddSequentialFunction · 0.76
benchmarkAddRandomFunction · 0.76
benchmarkFindSequentialFunction · 0.76
benchmarkFindRandomFunction · 0.76
benchmarkIterationFunction · 0.76
TestMaxGapAddRandomFunction · 0.64