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

Function orSparseWithDenseBitArray

bitarray/or.go:76–119  ·  view source on GitHub ↗
(sba *sparseBitArray, other *bitArray)

Source from the content-addressed store, hash-verified

74}
75
76func orSparseWithDenseBitArray(sba *sparseBitArray, other *bitArray) BitArray {
77 if other.Capacity() == 0 || !other.anyset {
78 return sba.copy()
79 }
80
81 if sba.Capacity() == 0 {
82 return other.copy()
83 }
84
85 max := maxUint64(uint64(sba.Capacity()), uint64(other.Capacity()))
86
87 ba := newBitArray(max * s)
88 selfIndex := 0
89 otherIndex := 0
90 for {
91 if selfIndex == len(sba.indices) && otherIndex == len(other.blocks) {
92 break
93 } else if selfIndex == len(sba.indices) {
94 copy(ba.blocks[otherIndex:], other.blocks[otherIndex:])
95 break
96 } else if otherIndex == len(other.blocks) {
97 for i, value := range sba.indices[selfIndex:] {
98 ba.blocks[value] = sba.blocks[i+selfIndex]
99 }
100 break
101 }
102
103 selfValue := sba.indices[selfIndex]
104 if selfValue == uint64(otherIndex) {
105 ba.blocks[otherIndex] = sba.blocks[selfIndex].or(other.blocks[otherIndex])
106 selfIndex++
107 otherIndex++
108 continue
109 }
110
111 ba.blocks[otherIndex] = other.blocks[otherIndex]
112 otherIndex++
113 }
114
115 ba.setHighest()
116 ba.setLowest()
117
118 return ba
119}
120
121func orDenseWithDenseBitArray(dba *bitArray, other *bitArray) BitArray {
122 if dba.Capacity() == 0 || !dba.anyset {

Callers 5

OrMethod · 0.85
OrMethod · 0.85

Calls 7

maxUint64Function · 0.85
newBitArrayFunction · 0.85
orMethod · 0.80
setHighestMethod · 0.80
setLowestMethod · 0.80
CapacityMethod · 0.65
copyMethod · 0.45

Tested by 3

Used in the wild real call sites across dependent graphs

searching dependent graphs…