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

Method Equals

bitarray/sparse_bitarray.go:208–247  ·  view source on GitHub ↗

Equals returns a bool indicating if the provided bit array equals this bitarray.

(other BitArray)

Source from the content-addressed store, hash-verified

206// Equals returns a bool indicating if the provided bit array
207// equals this bitarray.
208func (sba *sparseBitArray) Equals(other BitArray) bool {
209 if other.Capacity() == 0 && sba.Capacity() > 0 {
210 return false
211 }
212
213 var selfIndex uint64
214 for iter := other.Blocks(); iter.Next(); {
215 otherIndex, otherBlock := iter.Value()
216 if len(sba.indices) == 0 {
217 if otherBlock > 0 {
218 return false
219 }
220
221 continue
222 }
223
224 if selfIndex >= uint64(len(sba.indices)) {
225 return false
226 }
227
228 if otherIndex < sba.indices[selfIndex] {
229 if otherBlock > 0 {
230 return false
231 }
232 continue
233 }
234
235 if otherIndex > sba.indices[selfIndex] {
236 return false
237 }
238
239 if !sba.blocks[selfIndex].equals(otherBlock) {
240 return false
241 }
242
243 selfIndex++
244 }
245
246 return true
247}
248
249// Count returns the number of set bits in this array.
250func (sba *sparseBitArray) Count() int {

Callers

nothing calls this directly

Calls 6

CapacityMethod · 0.95
equalsMethod · 0.80
CapacityMethod · 0.65
BlocksMethod · 0.65
NextMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected