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

Method TryInsertWithoutMergingRange

pkg/segment/set.go:540–552  ·  view source on GitHub ↗

TryInsertWithoutMergingRange attempts to insert the given segment into the set. If successful, it 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, TryInsertWithoutMergingRange

(r Range, val Value)

Source from the content-addressed store, hash-verified

538// caller needs to do additional work between finding the gap and insertion,
539// use InsertWithoutMerging instead.
540func (s *Set) TryInsertWithoutMergingRange(r Range, val Value) Iterator {
541 if r.Length() <= 0 {
542 panic(fmt.Sprintf("invalid segment range %v", r))
543 }
544 seg, gap := s.Find(r.Start)
545 if seg.Ok() {
546 return Iterator{}
547 }
548 if gap.End() < r.End {
549 return Iterator{}
550 }
551 return s.InsertWithoutMerging(gap, r, val)
552}
553
554// Remove removes the given segment and returns an iterator to the vacated gap.
555// All existing iterators (including seg, but not including the returned

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected