(sba *sparseBitArray, other *bitArray)
| 84 | } |
| 85 | |
| 86 | func nandSparseWithDenseBitArray(sba *sparseBitArray, other *bitArray) BitArray { |
| 87 | // Since nand is non-commutative, the resulting array should be sparse, |
| 88 | // and the same length or less than the sparse array |
| 89 | indices := make(uintSlice, 0, len(sba.indices)) |
| 90 | blocks := make(blocks, 0, len(sba.indices)) |
| 91 | |
| 92 | var resultBlock block |
| 93 | |
| 94 | // Loop through the sparse array and match it with the dense array. |
| 95 | for selfIndex, selfValue := range sba.indices { |
| 96 | if selfValue >= uint64(len(other.blocks)) { |
| 97 | // Since the dense array is exhausted, just copy over the data |
| 98 | // from the sparse array |
| 99 | resultBlock = sba.blocks[selfIndex] |
| 100 | indices = append(indices, selfValue) |
| 101 | blocks = append(blocks, resultBlock) |
| 102 | continue |
| 103 | } |
| 104 | |
| 105 | resultBlock = sba.blocks[selfIndex].nand(other.blocks[selfValue]) |
| 106 | if resultBlock > 0 { |
| 107 | indices = append(indices, selfValue) |
| 108 | blocks = append(blocks, resultBlock) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return &sparseBitArray{ |
| 113 | indices: indices, |
| 114 | blocks: blocks, |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func nandDenseWithSparseBitArray(sba *bitArray, other *sparseBitArray) BitArray { |
| 119 | // Since nand is non-commutative, the resulting array should be dense, |
searching dependent graphs…