MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / appendCopiesAfter

Method appendCopiesAfter

roaring64/roaringarray64.go:93–116  ·  view source on GitHub ↗
(sa roaringArray64, beforeStart uint32)

Source from the content-addressed store, hash-verified

91}
92
93func (ra *roaringArray64) appendCopiesAfter(sa roaringArray64, beforeStart uint32) {
94 // cow only if the two request it, or if we already have a lightweight copy
95 copyonwrite := ra.copyOnWrite && sa.copyOnWrite
96
97 startLocation := sa.getIndex(beforeStart)
98 if startLocation >= 0 {
99 startLocation++
100 } else {
101 startLocation = -startLocation - 1
102 }
103
104 for i := startLocation; i < sa.size(); i++ {
105 thiscopyonewrite := copyonwrite || sa.needsCopyOnWrite(i)
106 if thiscopyonewrite {
107 ra.appendContainer(sa.keys[i], sa.containers[i], thiscopyonewrite)
108 if !sa.needsCopyOnWrite(i) {
109 sa.setNeedsCopyOnWrite(i)
110 }
111 } else {
112 // since there is no copy-on-write, we need to clone the container (this is important)
113 ra.appendContainer(sa.keys[i], sa.containers[i].Clone(), thiscopyonewrite)
114 }
115 }
116}
117
118func (ra *roaringArray64) removeIndexRange(begin, end int) {
119 if end <= begin {

Callers 2

FlipFunction · 0.45
TestCopiesFunction · 0.45

Calls 6

appendContainerMethod · 0.95
getIndexMethod · 0.45
sizeMethod · 0.45
needsCopyOnWriteMethod · 0.45
setNeedsCopyOnWriteMethod · 0.45
CloneMethod · 0.45

Tested by 1

TestCopiesFunction · 0.36