MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / Or

Method Or

libs/bits/bit_array.go:114–134  ·  view source on GitHub ↗

Or returns a bit array resulting from a bitwise OR of the two bit arrays. If the two bit-arrys have different lengths, Or right-pads the smaller of the two bit-arrays with zeroes. Thus the size of the return value is the maximum of the two provided bit arrays.

(o *BitArray)

Source from the content-addressed store, hash-verified

112// If the two bit-arrys have different lengths, Or right-pads the smaller of the two bit-arrays with zeroes.
113// Thus the size of the return value is the maximum of the two provided bit arrays.
114func (bA *BitArray) Or(o *BitArray) *BitArray {
115 if bA == nil && o == nil {
116 return nil
117 }
118 if bA == nil && o != nil {
119 return o.Copy()
120 }
121 if o == nil {
122 return bA.Copy()
123 }
124 bA.mtx.Lock()
125 o.mtx.Lock()
126 c := bA.copyBits(tmmath.MaxInt(bA.Bits, o.Bits))
127 smaller := tmmath.MinInt(len(bA.Elems), len(o.Elems))
128 for i := 0; i < smaller; i++ {
129 c.Elems[i] |= o.Elems[i]
130 }
131 bA.mtx.Unlock()
132 o.mtx.Unlock()
133 return c
134}
135
136// And returns a bit array resulting from a bitwise AND of the two bit arrays.
137// If the two bit-arrys have different lengths, this truncates the larger of the two bit-arrays from the right.

Callers 3

TestOrFunction · 0.80

Calls 5

CopyMethod · 0.95
copyBitsMethod · 0.95
CopyMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1

TestOrFunction · 0.64