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

Function newRunContainer16FromArray

runcontainer.go:255–281  ·  view source on GitHub ↗

newRunContainer16FromArray populates a new runContainer16 from the contents of arr.

(arr *arrayContainer)

Source from the content-addressed store, hash-verified

253// newRunContainer16FromArray populates a new
254// runContainer16 from the contents of arr.
255func newRunContainer16FromArray(arr *arrayContainer) *runContainer16 {
256 // keep this in sync with newRunContainer16FromVals above
257
258 rc := &runContainer16{}
259 ah := addHelper16{rc: rc}
260
261 n := arr.getCardinality()
262 var cur, prev uint16
263 switch {
264 case n == 0:
265 // nothing more
266 case n == 1:
267 ah.m = append(ah.m, newInterval16Range(arr.content[0], arr.content[0]))
268 ah.actuallyAdded++
269 default:
270 ah.runstart = arr.content[0]
271 ah.actuallyAdded++
272 for i := 1; i < n; i++ {
273 prev = arr.content[i-1]
274 cur = arr.content[i]
275 ah.add(cur, prev, i)
276 }
277 ah.storeIval(ah.runstart, ah.runlen)
278 }
279 rc.iv = ah.m
280 return rc
281}
282
283// set adds the integers in vals to the set. Vals
284// must be sorted in increasing order; if not, you should set

Callers 6

TestRleAndOrXor16Function · 0.85
TestRlePanics16Function · 0.85
toEfficientContainerMethod · 0.85

Calls 4

addMethod · 0.95
storeIvalMethod · 0.95
newInterval16RangeFunction · 0.85
getCardinalityMethod · 0.65

Tested by 4

TestRleAndOrXor16Function · 0.68
TestRlePanics16Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…