(sba *sparseBitArray, other *bitArray)
| 74 | } |
| 75 | |
| 76 | func 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 | |
| 121 | func orDenseWithDenseBitArray(dba *bitArray, other *bitArray) BitArray { |
| 122 | if dba.Capacity() == 0 || !dba.anyset { |
searching dependent graphs…