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

Method Sub

libs/bits/bit_array.go:182–203  ·  view source on GitHub ↗

Sub subtracts the two bit-arrays bitwise, without carrying the bits. Note that carryless subtraction of a - b is (a and not b). The output is the same as bA, regardless of o's size. If bA is longer than o, o is right padded with zeroes

(o *BitArray)

Source from the content-addressed store, hash-verified

180// The output is the same as bA, regardless of o's size.
181// If bA is longer than o, o is right padded with zeroes
182func (bA *BitArray) Sub(o *BitArray) *BitArray {
183 if bA == nil || o == nil {
184 // TODO: Decide if we should do 1's complement here?
185 return nil
186 }
187 bA.mtx.Lock()
188 o.mtx.Lock()
189 // output is the same size as bA
190 c := bA.copyBits(bA.Bits)
191 // Only iterate to the minimum size between the two.
192 // If o is longer, those bits are ignored.
193 // If bA is longer, then skipping those iterations is equivalent
194 // to right padding with 0's
195 smaller := tmmath.MinInt(len(bA.Elems), len(o.Elems))
196 for i := 0; i < smaller; i++ {
197 // &^ is and not in golang
198 c.Elems[i] &^= o.Elems[i]
199 }
200 bA.mtx.Unlock()
201 o.mtx.Unlock()
202 return c
203}
204
205// IsEmpty returns true iff all bits in the bit array are 0
206func (bA *BitArray) IsEmpty() bool {

Callers 15

TestSubFunction · 0.95
purgeExpiredTxsMethod · 0.80
GenPrivKeySecp256k1Function · 0.80
receiveRequestMethod · 0.80
crawlPeersMethod · 0.80
gossipDataRoutineMethod · 0.80
PickVoteToSendMethod · 0.80
scheduleRound0Method · 0.80
handleTxsAvailableMethod · 0.80
recordMetricsMethod · 0.80

Calls 3

copyBitsMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65

Tested by 2

TestSubFunction · 0.76