Or function that requires repairAfterLazy
(x1, x2 *Bitmap)
| 6 | |
| 7 | // Or function that requires repairAfterLazy |
| 8 | func lazyOR(x1, x2 *Bitmap) *Bitmap { |
| 9 | answer := NewBitmap() |
| 10 | pos1 := 0 |
| 11 | pos2 := 0 |
| 12 | length1 := x1.highlowcontainer.size() |
| 13 | length2 := x2.highlowcontainer.size() |
| 14 | main: |
| 15 | for (pos1 < length1) && (pos2 < length2) { |
| 16 | s1 := x1.highlowcontainer.getKeyAtIndex(pos1) |
| 17 | s2 := x2.highlowcontainer.getKeyAtIndex(pos2) |
| 18 | |
| 19 | for { |
| 20 | if s1 < s2 { |
| 21 | answer.highlowcontainer.appendCopy(x1.highlowcontainer, pos1) |
| 22 | pos1++ |
| 23 | if pos1 == length1 { |
| 24 | break main |
| 25 | } |
| 26 | s1 = x1.highlowcontainer.getKeyAtIndex(pos1) |
| 27 | } else if s1 > s2 { |
| 28 | answer.highlowcontainer.appendCopy(x2.highlowcontainer, pos2) |
| 29 | pos2++ |
| 30 | if pos2 == length2 { |
| 31 | break main |
| 32 | } |
| 33 | s2 = x2.highlowcontainer.getKeyAtIndex(pos2) |
| 34 | } else { |
| 35 | c1 := x1.highlowcontainer.getContainerAtIndex(pos1) |
| 36 | answer.highlowcontainer.appendContainer(s1, c1.lazyOR(x2.highlowcontainer.getContainerAtIndex(pos2)), false) |
| 37 | pos1++ |
| 38 | pos2++ |
| 39 | if (pos1 == length1) || (pos2 == length2) { |
| 40 | break main |
| 41 | } |
| 42 | s1 = x1.highlowcontainer.getKeyAtIndex(pos1) |
| 43 | s2 = x2.highlowcontainer.getKeyAtIndex(pos2) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | if pos1 == length1 { |
| 48 | answer.highlowcontainer.appendCopyMany(x2.highlowcontainer, pos2, length2) |
| 49 | } else if pos2 == length2 { |
| 50 | answer.highlowcontainer.appendCopyMany(x1.highlowcontainer, pos1, length1) |
| 51 | } |
| 52 | return answer |
| 53 | } |
| 54 | |
| 55 | // In-place Or function that requires repairAfterLazy |
| 56 | func (x1 *Bitmap) lazyOR(x2 *Bitmap) *Bitmap { |
no test coverage detected
searching dependent graphs…