MCPcopy Create free account
hub / github.com/google/gapid / cut

Function cut

core/math/interval/algorithm.go:114–147  ·  view source on GitHub ↗

cut slices a hole matching the specified span from a list. If add is true, it puts a new span in that space It is used to implement both Remove and Replace

(l MutableList, span U64Span, add bool)

Source from the content-addressed store, hash-verified

112// If add is true, it puts a new span in that space
113// It is used to implement both Remove and Replace
114func cut(l MutableList, span U64Span, add bool) (int, U64Span) {
115 s := intersection{}
116 s.intersect(l, span, false)
117 if s.overlap == 0 {
118 if add {
119 adjust(l, s.lowIndex, 1)
120 }
121 return s.lowIndex, span
122 }
123
124 insertLen := 0
125 insertPoint := s.lowIndex
126 if s.intersectsLow {
127 s.low.End = span.Start
128 insertLen++
129 insertPoint++
130 }
131 if add {
132 insertLen++
133 }
134 if s.intersectsHigh {
135 s.high.Start = span.End
136 insertLen++
137 }
138 delta := insertLen - s.overlap
139 adjust(l, insertPoint, delta)
140 if s.intersectsLow {
141 l.SetSpan(s.lowIndex, s.low)
142 }
143 if s.intersectsHigh {
144 l.SetSpan(s.lowIndex+insertLen-1, s.high)
145 }
146 return insertPoint, span
147}
148
149// adjust implements list size adjustment logic, given a delta in size, and an
150// index to adjust at

Callers 2

ReplaceFunction · 0.85
RemoveFunction · 0.85

Calls 3

intersectMethod · 0.95
adjustFunction · 0.85
SetSpanMethod · 0.65

Tested by

no test coverage detected