Or computes the union between two bitmaps and stores the result in the current bitmap
(x2 *Bitmap)
| 1627 | |
| 1628 | // Or computes the union between two bitmaps and stores the result in the current bitmap |
| 1629 | func (rb *Bitmap) Or(x2 *Bitmap) { |
| 1630 | pos1 := 0 |
| 1631 | pos2 := 0 |
| 1632 | length1 := rb.highlowcontainer.size() |
| 1633 | length2 := x2.highlowcontainer.size() |
| 1634 | main: |
| 1635 | for (pos1 < length1) && (pos2 < length2) { |
| 1636 | s1 := rb.highlowcontainer.getKeyAtIndex(pos1) |
| 1637 | s2 := x2.highlowcontainer.getKeyAtIndex(pos2) |
| 1638 | |
| 1639 | for { |
| 1640 | if s1 < s2 { |
| 1641 | pos1++ |
| 1642 | if pos1 == length1 { |
| 1643 | break main |
| 1644 | } |
| 1645 | s1 = rb.highlowcontainer.getKeyAtIndex(pos1) |
| 1646 | } else if s1 > s2 { |
| 1647 | rb.highlowcontainer.insertNewKeyValueAt(pos1, s2, x2.highlowcontainer.getContainerAtIndex(pos2).clone()) |
| 1648 | pos1++ |
| 1649 | length1++ |
| 1650 | pos2++ |
| 1651 | if pos2 == length2 { |
| 1652 | break main |
| 1653 | } |
| 1654 | s2 = x2.highlowcontainer.getKeyAtIndex(pos2) |
| 1655 | } else { |
| 1656 | newcont := rb.highlowcontainer.getUnionedWritableContainer(pos1, x2.highlowcontainer.getContainerAtIndex(pos2)) |
| 1657 | rb.highlowcontainer.replaceKeyAndContainerAtIndex(pos1, s1, newcont, false) |
| 1658 | pos1++ |
| 1659 | pos2++ |
| 1660 | if (pos1 == length1) || (pos2 == length2) { |
| 1661 | break main |
| 1662 | } |
| 1663 | s1 = rb.highlowcontainer.getKeyAtIndex(pos1) |
| 1664 | s2 = x2.highlowcontainer.getKeyAtIndex(pos2) |
| 1665 | } |
| 1666 | } |
| 1667 | } |
| 1668 | if pos1 == length1 { |
| 1669 | rb.highlowcontainer.appendCopyMany(x2.highlowcontainer, pos2, length2) |
| 1670 | } |
| 1671 | } |
| 1672 | |
| 1673 | // AndNot computes the difference between two bitmaps and stores the result in the current bitmap |
| 1674 | func (rb *Bitmap) AndNot(x2 *Bitmap) { |