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

Method Not

runcontainer.go:2098–2122  ·  view source on GitHub ↗

Not flips the values in the range [firstOfRange,endx). This is not inplace. Only the returned value has the flipped bits. Currently implemented as (!A intersect B) union (A minus B), where A is rc, and B is the supplied [firstOfRange, endx) interval. TODO(time optimization): convert this to a sing

(firstOfRange, endx int)

Source from the content-addressed store, hash-verified

2096// makes 2 more passes through the arrays than should be
2097// strictly necessary. Measure both ways though--this may not matter.
2098func (rc *runContainer16) Not(firstOfRange, endx int) *runContainer16 {
2099 if firstOfRange > endx {
2100 panic(fmt.Sprintf("invalid %v = endx > firstOfRange == %v", endx, firstOfRange))
2101 }
2102
2103 if firstOfRange >= endx {
2104 return rc.Clone()
2105 }
2106
2107 a := rc
2108 // algo:
2109 // (!A intersect B) union (A minus B)
2110
2111 nota := a.invert()
2112
2113 bs := []interval16{newInterval16Range(uint16(firstOfRange), uint16(endx-1))}
2114 b := newRunContainer16TakeOwnership(bs)
2115
2116 notAintersectB := nota.intersect(b)
2117
2118 aMinusB := a.AndNotRunContainer16(b)
2119
2120 rc2 := notAintersectB.union(aMinusB)
2121 return rc2
2122}
2123
2124// equals is now logical equals; it does not require the
2125// same underlying container type.

Callers 5

notMethod · 0.95
inotMethod · 0.95
minOrMaxMethod · 0.80

Calls 7

CloneMethod · 0.95
newInterval16RangeFunction · 0.85
invertMethod · 0.80
intersectMethod · 0.80
AndNotRunContainer16Method · 0.80
unionMethod · 0.80

Tested by 1