MCPcopy
hub / github.com/RoaringBitmap/roaring / appendCopiesAfter

Method appendCopiesAfter

roaringarray.go:204–227  ·  view source on GitHub ↗
(sa roaringArray, beforeStart uint16)

Source from the content-addressed store, hash-verified

202}
203
204func (ra *roaringArray) appendCopiesAfter(sa roaringArray, beforeStart uint16) {
205 // cow only if the two request it, or if we already have a lightweight copy
206 copyonwrite := ra.copyOnWrite && sa.copyOnWrite
207
208 startLocation := sa.getIndex(beforeStart)
209 if startLocation >= 0 {
210 startLocation++
211 } else {
212 startLocation = -startLocation - 1
213 }
214
215 for i := startLocation; i < sa.size(); i++ {
216 thiscopyonewrite := copyonwrite || sa.needsCopyOnWrite(i)
217 if thiscopyonewrite {
218 ra.appendContainer(sa.keys[i], sa.containers[i], thiscopyonewrite)
219 if !sa.needsCopyOnWrite(i) {
220 sa.setNeedsCopyOnWrite(i)
221 }
222 } else {
223 // since there is no copy-on-write, we need to clone the container (this is important)
224 ra.appendContainer(sa.keys[i], sa.containers[i].clone(), thiscopyonewrite)
225 }
226 }
227}
228
229func (ra *roaringArray) removeIndexRange(begin, end int) {
230 if end <= begin {

Callers 1

FlipFunction · 0.45

Calls 6

appendContainerMethod · 0.95
cloneMethod · 0.65
getIndexMethod · 0.45
sizeMethod · 0.45
needsCopyOnWriteMethod · 0.45
setNeedsCopyOnWriteMethod · 0.45

Tested by

no test coverage detected