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)
| 2096 | // makes 2 more passes through the arrays than should be |
| 2097 | // strictly necessary. Measure both ways though--this may not matter. |
| 2098 | func (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. |