And returns a bit array resulting from a bitwise AND of the two bit arrays. If the two bit-arrys have different lengths, this truncates the larger of the two bit-arrays from the right. Thus the size of the return value is the minimum of the two provided bit arrays.
(o *BitArray)
| 137 | // If the two bit-arrys have different lengths, this truncates the larger of the two bit-arrays from the right. |
| 138 | // Thus the size of the return value is the minimum of the two provided bit arrays. |
| 139 | func (bA *BitArray) And(o *BitArray) *BitArray { |
| 140 | if bA == nil || o == nil { |
| 141 | return nil |
| 142 | } |
| 143 | bA.mtx.Lock() |
| 144 | o.mtx.Lock() |
| 145 | defer func() { |
| 146 | bA.mtx.Unlock() |
| 147 | o.mtx.Unlock() |
| 148 | }() |
| 149 | return bA.and(o) |
| 150 | } |
| 151 | |
| 152 | func (bA *BitArray) and(o *BitArray) *BitArray { |
| 153 | c := bA.copyBits(tmmath.MinInt(bA.Bits, o.Bits)) |