Intersects returns a bool indicating if the provided bit array intersects with this bitarray.
(other BitArray)
| 305 | // Intersects returns a bool indicating if the provided bit array |
| 306 | // intersects with this bitarray. |
| 307 | func (sba *sparseBitArray) Intersects(other BitArray) bool { |
| 308 | if other.Capacity() == 0 { |
| 309 | return true |
| 310 | } |
| 311 | |
| 312 | var selfIndex int64 |
| 313 | for iter := other.Blocks(); iter.Next(); { |
| 314 | otherI, otherBlock := iter.Value() |
| 315 | if len(sba.indices) == 0 { |
| 316 | if otherBlock > 0 { |
| 317 | return false |
| 318 | } |
| 319 | continue |
| 320 | } |
| 321 | // here we grab where the block should live in ourselves |
| 322 | i := uintSlice(sba.indices[selfIndex:]).search(otherI) |
| 323 | // this is a block we don't have, doesn't intersect |
| 324 | if i == int64(len(sba.indices)) { |
| 325 | return false |
| 326 | } |
| 327 | |
| 328 | if sba.indices[i] != otherI { |
| 329 | return false |
| 330 | } |
| 331 | |
| 332 | if !sba.blocks[i].intersects(otherBlock) { |
| 333 | return false |
| 334 | } |
| 335 | |
| 336 | selfIndex = i |
| 337 | } |
| 338 | |
| 339 | return true |
| 340 | } |
| 341 | |
| 342 | func (sba *sparseBitArray) IntersectsBetween(other BitArray, start, stop uint64) bool { |
| 343 | return true |