MCPcopy Index your code
hub / github.com/Workiva/go-datastructures / Intersects

Method Intersects

bitarray/sparse_bitarray.go:307–340  ·  view source on GitHub ↗

Intersects returns a bool indicating if the provided bit array intersects with this bitarray.

(other BitArray)

Source from the content-addressed store, hash-verified

305// Intersects returns a bool indicating if the provided bit array
306// intersects with this bitarray.
307func (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
342func (sba *sparseBitArray) IntersectsBetween(other BitArray, start, stop uint64) bool {
343 return true

Callers

nothing calls this directly

Calls 7

uintSliceTypeAlias · 0.85
intersectsMethod · 0.80
CapacityMethod · 0.65
BlocksMethod · 0.65
NextMethod · 0.65
ValueMethod · 0.65
searchMethod · 0.65

Tested by

no test coverage detected