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

Method Equals

bitarray/bitarray.go:257–290  ·  view source on GitHub ↗

Equals returns a bool indicating if these two bit arrays are equal.

(other BitArray)

Source from the content-addressed store, hash-verified

255
256// Equals returns a bool indicating if these two bit arrays are equal.
257func (ba *bitArray) Equals(other BitArray) bool {
258 if other.Capacity() == 0 && ba.highest > 0 {
259 return false
260 }
261
262 if other.Capacity() == 0 && !ba.anyset {
263 return true
264 }
265
266 var selfIndex uint64
267 for iter := other.Blocks(); iter.Next(); {
268 toIndex, otherBlock := iter.Value()
269 if toIndex > selfIndex {
270 for i := selfIndex; i < toIndex; i++ {
271 if ba.blocks[i] > 0 {
272 return false
273 }
274 }
275 }
276
277 selfIndex = toIndex
278 if !ba.blocks[selfIndex].equals(otherBlock) {
279 return false
280 }
281 selfIndex++
282 }
283
284 lastIndex, _ := getIndexAndRemainder(ba.highest)
285 if lastIndex >= selfIndex {
286 return false
287 }
288
289 return true
290}
291
292// Intersects returns a bool indicating if the supplied bitarray intersects
293// this bitarray. This will check for intersection up to the length of the supplied

Callers

nothing calls this directly

Calls 6

getIndexAndRemainderFunction · 0.85
equalsMethod · 0.80
CapacityMethod · 0.65
BlocksMethod · 0.65
NextMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected