FastAnd computes the intersection between many bitmaps quickly Compared to the And function, it can take many bitmaps as input, thus saving the trouble of manually calling "And" many times. Performance hints: if you have very large and tiny bitmaps, it may be beneficial performance-wise to put a ti
(bitmaps ...*Bitmap)
| 133 | // it may be beneficial performance-wise to put a tiny bitmap |
| 134 | // in first position. |
| 135 | func FastAnd(bitmaps ...*Bitmap) *Bitmap { |
| 136 | if len(bitmaps) == 0 { |
| 137 | return NewBitmap() |
| 138 | } else if len(bitmaps) == 1 { |
| 139 | return bitmaps[0].Clone() |
| 140 | } |
| 141 | answer := And(bitmaps[0], bitmaps[1]) |
| 142 | for _, bm := range bitmaps[2:] { |
| 143 | answer.And(bm) |
| 144 | } |
| 145 | return answer |
| 146 | } |
| 147 | |
| 148 | // FastOr computes the union between many bitmaps quickly, as opposed to having to call Or repeatedly. |
| 149 | // It might also be faster than calling Or repeatedly. |
searching dependent graphs…